The browser’s window is represented by a global object called window object. The window object can be manipulated by DOM (Document Object Module), BOM (Browser Object Model) and JavaScript references (Object, Array, Function…). 

JavaScript Window Object reference branches

 

 

 

 

 

BOM is a collection of methods and properties implemented by browsers to control browser attributes like frames, server requests, current URL and functions like alerts. BOM is not standardized by ECMAScript, though it is described as core part of JavaScript.

The core BOM's object is window, which represents all the elements of browser such as location, history, frame…etc (but does not include page content). All the elements of the browser are properties or methods of a window object, which enables programmer to manipulate them through JavaScript. 

Few examples of window object properties and methods are listed below:

  • window.frames[0].location = "http://google.com/";
  • var width = window.innerwidth;
  • var h = window.innerHeight;
  • window.open(“”, window1, “width=400, height=400”);
  • window.close();
  • window1.moveTo(600, 200);
  • window1.focus();

Global Objects

All global objects, functions, variables of JavaScript are members of Window object by default. JS allows window reference to be omitted while accessing most of its elements. The document element which is root of DOM elements are part of BOM in object hierarchy.

Example of Global objects

Both the below statements mean the same:

window.document.getElementById(“header”);

document.getElementById(“header”);

You can also find more about global objects at this location... 

 

›› go to examples ››