Window Object in JavaScript

Window Object in JavaScript

·

3 min read

The most important object in the Browser Object Model is the window object.

It helps in accessing information about the browser and its components. To access these features, it has various methods and properties.

Property Description
window.closed Whether the window has been closed
window.length Number of <iframe> elements in the window
window.name Gets or sets the window name
window.innerHeight height of the window
window.innerWidth width of the window
window.screenX X-cordinate of the pointer, relative to the top left corner of screen
window.screenY Y-cordinate of the pointer, relative to the top left corner of screen
window.location current URL of window object
window.history Reference to history object for browser window or tab
window.screen Reference to object
window.pageXoffset Distance document has been scrolled horizantally
window.pageYoffset Distance document has been scrolled vertically
window.alert() creates dialog box with message OK button
window.blur() Remove focus from window
window.close() closes a browser window
window.confirm() Creates dialog box with message, and OK button and a cancel button
window.getComputedStyle() Get CSS styles applied to an element
window.moveTo(x,y) Move a window's left and top edge to supplied coordinates
window.open() Opens new browser window with URL specified as parameter
window.print() Tells browser that user wants to print contents of current page
window.prompt() Creates dialog box for retrieving user input
windows.scrollBy() Scroll the document by the specified number of pixels
windows.scrollTo() Scolls the document to the specified coordinates
window.setInterval() Do something repeatedly at specified intervals
windows.setTimeOut() Do something after a specified amount of time
window.stop() Stop window from loading


Short and Informative Post for you all. 😀 ⚡Happy Coding

Did you find this article valuable?

Support Rahul by becoming a sponsor. Any amount is appreciated!