JavaScript Window - The Browser Object Model

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

The Browser Object Model (BOM)

There are no official norms for the Browser Object Model (BOM).

Since present day programs have executed (nearly) similar strategies and properties for JavaScript intuitiveness, it is frequently alluded to, as strategies and properties of the BOM.

The Window Object

The window object is upheld by all programs. It speaks to the program's window.

All worldwide JavaScript articles, capacities, and factors naturally move toward becoming individuals from the window object.

Global factors are properties of the window object.

Global capacities are strategies for the window object.

Even the archive object (of the HTML DOM) is a property of the window object:


is the equivalent as:


Window Size

Two properties can be utilized to decide the span of the program window.

Both properties return the sizes in pixels:

  • window.innerHeight - the inward tallness of the program window (in pixels)
  • window.innerWidth - the inward width of the program window (in pixels)

For Internet Explorer 8, 7, 6, 5:

  • document.documentElement.clientHeight
  • document.documentElement.clientWidth
  • or
  • document.body.clientHeight
  • document.body.clientWidth

A reasonable JavaScript arrangement (covering all programs):


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

var h = window.innerHeight
|| document.documentElement.clientHeight
|| document.body.clientHeight;
Try it yourself »

The model shows the program window's tallness and width: (excluding toolbars/scrollbars)

Other Window Methods

Some other methods:

  • window.open() - open another window
  • window.close() - close the current window
  • window.moveTo() - move the current window
  • window.resizeTo() - resize the current window