The Browser Object Model (BOM) allows JavaScript to "talk to" the browser. While there are no official standards for the BOM, most modern browsers use the same properties and methods.
The window object is supported by all browsers. It represents the
browser's window and is the global object for all JavaScript elements.
document object (of the HTML DOM) is a property
of the window object!You can determine the size of the browser window (the viewport) using two properties. These values are in pixels and do not include toolbars or scrollbars.
window.innerWidth: The inner width of the browser window.
window.innerHeight: The inner height of the browser
window.let width = window.innerWidth;
let height = window.innerHeight;
The window object provides several methods to control browser behavior:
window.open(): Opens a new window.window.close(): Closes the current window.window.moveTo(): Moves the current window.window.resizeTo(): Resizes the current window.While the DOM focuses on the content *inside* the page, the BOM focus on the environment *surrounding* the page (the browser window).
window is the global object, you don't even
have to write the window. prefix. window.alert() is the same as
alert()!
window object is the "Father" of all browser objects
innerWidth/innerHeight return viewport dimensionswindow. prefix for global methodsdocument object is actually a sub-property:
window.document