The Window object represents the window opened in the browser.
If the document contains frames (<frame> or <iframe> tags), the browser creates a window object for the HTML document and creates an additional window object for each frame.
Window object properties
Attributes | description |
---|---|
closed | Returns whether the window has been closed |
defaultStatus | Set or return to the default text in the window status bar |
document | Read-only reference to Document object |
frames | Returns all named frames in the window. The collection is an array of Window objects, each Window object contains a frame in the window |
history | Read-only reference to History object |
innerHeight | Returns the height of the document display area of the window |
innerWidth | Returns the width of the document display area of the window |
length | Sets or returns the number of frames in the window |
location | Location object for window or frame |
name | Set or return the name of the window |
navigator | Read-only reference to Navigator object |
opener | Returns a reference to the window that created this window |
outerHeight | Returns the outer height of the window, including toolbars and scroll bars |
outerWidth | Returns the outer width of the window, including toolbars and scroll bars |
pageXOffset | Sets or returns the X position of the current page relative to the upper left corner of the window display area |
pageYOffset | Sets or returns the Y position of the current page relative to the upper left corner of the window display area |
parent | Return to parent window |
screen | Read-only reference to Screen object |
screenLeft | Returns the x coordinate relative to the screen window |
screenTop | Returns the y coordinate relative to the screen window |
screenX | Returns the x coordinate relative to the screen window |
screenY | Returns the y coordinate relative to the screen window |
self | Return a reference to the current window |
status | Set the text of the window status bar |
top | Return to the topmost parent window |
Window object methods
method | description |
---|---|
alert() | Display a warning box with a message and a confirmation button |
blur() | Move the keyboard focus away from the top window |
clearInterval() | Cancel the timeout set by setInterval () |
clearTimeout() | Cancel the timeout set by the setTimeout () method |
close() | Close browser window |
confirm() | Display a dialog box with a message and confirmation button and cancel button |
createPopup() | Create a pop-up window |
focus() | Give keyboard focus to a window |
moveBy() | It can be moved by a specified pixel relative to the current coordinates of the window |
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() | Display a dialog 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 |
scrollBy() | Scroll content according to specified pixel value |
scrollTo() | Scroll content to specified coordinates |
setInterval() | Call a function or calculation expression at a specified period (in milliseconds) |
setTimeout() | Call the function or calculation expression after the specified number of milliseconds |
Mind map of JS Window object learning
Excerpt from W3Cschool .