Window object


Window Object


Window Object

The Window object represents the window open in the browser.

If the document contains frames (<frame> or <iframe> tags), the browser creates a window object for the HTML document and an additional window object for each frame.

NoteNote: There is no public standard for the window object, but all browsers support it.


Window object properties

PropertiesDescription
closedReturns whether the window has been closed.
defaultStatusSet or return the default text in the window status bar.
documentA read-only reference to the Document object. (See Object)
#framesReturns all named frames in the window. The collection is an array of Window objects, each of which contains a frame within the window.
historyA read-only reference to the History object. Please parameter History object.
innerHeightReturns the height of the document display area of ​​the window.
innerWidthReturns the width of the document display area of ​​the window.
lengthSet or return the number of frames in the window.
locationThe Location object used for the window or frame. See Location object.
nameSets or returns the name of the window.
navigatorA read-only reference to the Navigator object. Please parameterize the Navigator object.
opener Returns a reference to the window that created this window.
outerHeightReturns the outer height of the window, including toolbars and scroll bars.
outerWidthReturns the outer width of the window, including toolbars and scroll bars.
pageXOffsetSet or return the X position of the current page relative to the upper left corner of the window display area.
pageYOffsetSet or return the Y position of the current page relative to the upper left corner of the window display area.
parent Return to the parent window.
screenA read-only reference to the Screen object. Please parameterize Screen object.
screenLeft Returns the x coordinate relative to the screen window
screenTop Returns relative to the screen The y coordinate of the window
screenX Returns the x coordinate relative to the screen window
screenY Returns the y coordinate relative to the screen window
selfReturns a reference to the current window. Equivalent to the Window property.
statusSet the text of the window status bar.
top Returns the top-most parent window.

Window object methods

MethodDescription
alert() Displays an alert box with a message and a confirm button.
blur()Removes the keyboard focus from the top-level window.
clearInterval()Cancel the timeout set by setInterval().
clearTimeout()Cancel the timeout set by the setTimeout() method.
close()Close the browser window.
confirm()Displays a dialog box with a message and confirm and cancel buttons.
createPopup()Create a pop-up window.
focus()Give keyboard focus to a window.
moveBy() can move the window by the specified pixels relative to its current coordinates.
moveTo()Move the upper left corner of the window to a specified coordinate.
open()Open a new browser window or find a named window.
print()Print the contents of the current window.
prompt()Displays a dialog box that prompts the user for input.
resizeBy()Resize the window according to the specified pixels.
resizeTo()Resize the window to the specified width and height.
scroll()
scrollBy()Scroll the content according to the specified pixel value .
scrollTo()Scroll the content to the specified coordinates.
setInterval()Call a function or calculate an expression according to the specified period (in milliseconds).
setTimeout()Calls a function or calculated expression after the specified number of milliseconds.