BOM Stands for Browser Object Model. BOM is an
object structure created by a browser for any webpage. It is a hierarchy of browser objects which allow
window object represents the frame or window in which the webpage is contained in the
window object is a Global object, its properties and functions can be accessed
without referring to it. Example:
window.alert() is used to alert something but we can directly
alert() without referring to window object.
window is the root object, even the document is the property of the
object. it can be used to find out screen height, screen width, history, localStorage, location, events etc.
Everything that is visible and non-visible on a webpage all are part of the
window object has 4 different properties to get the height and width of the window.
Two properties represent inner dimensions of window :
To use this property use it with a window object, see in the example.
The other two properties represent outer dimension of window :
window interface has the
open() method which loads a new window or new tab on
the browser with a given URL.
window.open(URL, windowName, [windowFeatures]);
- URL: The url address you want to go
- windowName: (Optional) window name is given as a target for hyperlinks and forms. However it is not required, window need not to have name
- windowFeatures: This contains a comma separated a list of features in form of "name=value". These features includes options such as position, size, weather or not to include toolbar etc.
Resize a window
window interface has
resizeTo() method which can resize the size of window to
the passed value. Example
To close a window use
close() method referring to the window object which you want to close.