Easy Tutorial
❮ Js Loop While Jsref Obj Date ❯

JavaScript Window - Browser Object Model


The Browser Object Model (BOM) allows JavaScript to "talk" to the browser.


Browser Object Model (BOM)

The Browser Object Model (Browser Object Model (BOM)) has no official standards.

Since modern browsers have (almost) implemented the same methods and properties for JavaScript interactivity, they are often considered as methods and properties of BOM.


Window Object

All browsers support the window object. It represents the browser window.

All JavaScript global objects, functions, and variables automatically become members of the window object.

Global variables are properties of the window object.

Global functions are methods of the window object.

Even the HTML DOM document is a property of the window object:

window.document.getElementById("header");

This is the same as:

document.getElementById("header");

Window Dimensions

There are three methods to determine the dimensions of the browser window.

For Internet Explorer, Chrome, Firefox, Opera, and Safari:

For Internet Explorer 8, 7, 6, 5:

Or

A practical JavaScript solution (covering all browsers, including IE8 and below):

Example

var w = window.innerWidth
|| document.documentElement.clientWidth
|| document.body.clientWidth;

var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;

This example displays the height and width of the browser window.


Other Window Methods

Some other methods:

❮ Js Loop While Jsref Obj Date ❯