📜  窗口对象的属性

📅  最后修改于: 2022-05-13 01:56:50.104000             🧑  作者: Mango

窗口对象的属性

window 对象是 DOM 层次结构的最顶层对象。它表示显示网页内容的浏览器窗口或框架。每当屏幕上出现一个显示文档内容的窗口时,就会创建窗口对象。 Window对象常用的属性和方法如下表所示:

窗口对象的属性

Property Name

Purpose

ClosedIt holds a Boolean value that represents whether the window is closed or not.
consoleIt returns a reference to the console object which provides access to the browser’s debugging console.
defaultStatusIt is used to define the default message that will be displayed in the status bar when no activity is carried on by the browser.
controllersIt returns the XUL controller objects for the current Chrome window.
customElementsIt returns a reference to the CustomElementRegistry object, which can be used to register new custom elements and also get information about already registered custom elements.
cryptoIt returns the browser crypto object.
devicePixelRatioIt returns the ratio between physical pixels and device independent pixels in the current display.
DocumentIt returns a reference to the document object of that window.
DOMMatrixIt returns a reference to a DOMMatrix object, which represents 4×4 matrices, suitable for 2D and 3D operations.
frames[]It represents an array that contains all the frames of a given window.
DOMPointIt returns a reference to a DOMPoint object, which represents a 2D or 3D point in a coordinate system.
HistoryIt provides information of the URLs visited in the current window.
LengthIt represents the number of frames in the current window.
DOMRectIt returns a reference to a DOMRect object, which represents a rectangle.
fullScreenThis property indicates whether the window is displayed in full screen or not.
LocationIt contains the URL of the current window.
innerHeightIt is used to get the height of the content area of the browser window.
innerWidthIt is used to get the width of the content area of the browser window.
NameIt contains name of the referenced window.
OpenerIt contains a reference to the window that opened the current window.
ParentIt refers to the frame set in which the current frame is contained.
ScreenIt refers to the screen object
SelfIt provides another way to refer the current window.
StatusIt overrides the defaultStatus and places a message in the status bar.
TopIt returns a reference to the topmost window containing a frame if many windows are opened.
WindowIt returns the current window or frame.
NavigatorIt returns a reference to the navigator object.
outerHeightIt will get height of the outside of the browser window.
outerWidthIt will get width of the outside of the browser window.
ToolbarIt will result the toolbar object, whose visibility can be toggled in the window.

要访问窗口对象的属性,您将指定对象名称,后跟句号 (.) 和属性名称。

句法:

window.property_name

例子:

HTML


 

    

 

    

 


输出:

点击按钮前:

点击按钮后: