window object represents the frame or window in which the webpage is contained in the browser. 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 use
alert() without referring to window object.
window is the root object, even the document is the property of the
window 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.
- 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 seperated 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.