← 7 Loading web pages — Table of Contents — 7.3 Origin → 7.2 The Window
object7.2.1 APIs for creating and navigating browsing contexts by name7.2.2 Accessing other browsing contexts7.2.3 Named access on the Window
object7.2.4 Closing browsing contexts7.2.5 Browser interface elements7.2 The Window
object
window . window
✔ MDN Window/window
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 12+ Internet Explorer ? Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes window . frames
✔ MDN Window/frames
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 12+ Internet Explorer Yes Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes window . self
✔ MDN Window/self
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 12+ Internet Explorer Yes Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes
These attributes all return window .
window . document
✔ MDN Window/document
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 12+ Internet Explorer Yes Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes
Returns the Document
associated with window .
document . defaultView
✔ MDN Document/defaultView
Support in all current engines.
Firefox Yes Safari Yes Chrome 1+
Opera Yes Edge 79+ Edge (Legacy) 12+ Internet Explorer 9+ Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes
Returns the Window
object of the active document .
7.2.1 APIs for creating and navigating browsing contexts by name
window = window . open
( [ url [, target [, features ] ] ] )✔ MDN Window/open
Support in all current engines.
Firefox 1+ Safari 1+ Chrome 1+
Opera 3+ Edge 79+ Edge (Legacy) 12+ Internet Explorer 4+ Firefox Android 4+ Safari iOS 1+ Chrome Android 18+ WebView Android 1+ Samsung Internet 1.0+ Opera Android 10.1+
Opens a window to show url (defaults to about:blank
), and returns it.
The target argument gives the name of the new window. If a window exists with that
name already, it is reused. The features argument can be used to influence the
rendering of the new window.
window . name
[ = value ]✔ MDN Window/name
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 12+ Internet Explorer ? Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes
Returns the name of the window.
Can be set, to change the name.
window . close
()✔ MDN Window/close
Support in all current engines.
Firefox 1+ Safari 1+ Chrome 1+
Opera 3+ Edge 79+ Edge (Legacy) 12+ Internet Explorer 4+ Firefox Android 4+ Safari iOS 1+ Chrome Android 18+ WebView Android 1+ Samsung Internet 1.0+ Opera Android 10.1+
Closes the window.
window . closed
Returns true if the window has been closed, false otherwise.
window . stop
()✔ MDN Window/stop
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 14+ Internet Explorer No Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes
Cancels the document load.
7.2.2 Accessing other browsing contexts
window . length
✔ MDN Window/length
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 12+ Internet Explorer ? Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes
Returns the number of document-tree child browsing contexts .
window [index ]
Returns the indicated document-tree child browsing context .
7.2.3 Named access on the Window
object
window [name ]
Returns the indicated element or collection of elements.
As a general rule, relying on this will lead to brittle code. Which IDs end up mapping to
this API can vary over time, as new features are added to the web platform, for example. Instead
of this, use document.getElementById()
or document.querySelector()
.
7.2.4 Closing browsing contexts
To close a browsing context browsingContext , run these steps:
Prompt to unload browsingContext 's active document .
If the user refused to allow the document to be unloaded , then return.
Unload browsingContext 's active
document .
Remove browsingContext from the user interface (e.g., close or hide its tab in
a tabbed browser).
Discard
browsingContext .
User agents should offer users the ability to arbitrarily close any top-level browsing context .
7.2.5 Browser interface elements
To allow web pages to integrate with web browsers, certain web browser interface elements are
exposed in a limited way to scripts in web pages.
Each interface element is represented by a BarProp
object:
window . locationbar
. visible
✔ MDN Window/locationbar
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 12+ Internet Explorer No Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes
Returns true if the location bar is visible; otherwise, returns false.
window . . visible
✔ MDN Window/menubar
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 12+ Internet Explorer No Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes
Returns true if the menu bar is visible; otherwise, returns false.
window . personalbar
. visible
✔ MDN Window/personalbar
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 12+ Internet Explorer No Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes
Returns true if the personal bar is visible; otherwise, returns false.
window . scrollbars
. visible
✔ MDN Window/scrollbars
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 12+ Internet Explorer No Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes
Returns true if the scrollbars are visible; otherwise, returns false.
window . statusbar
. visible
✔ MDN Window/statusbar
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 12+ Internet Explorer No Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes
Returns true if the status bar is visible; otherwise, returns false.
window . toolbar
. visible
✔ MDN Window/toolbar
Support in all current engines.
Firefox Yes Safari Yes Chrome Yes
Opera Yes Edge Yes Edge (Legacy) 12+ Internet Explorer No Firefox Android Yes Safari iOS Yes Chrome Android Yes WebView Android Yes Samsung Internet Yes Opera Android Yes
Returns true if the toolbar is visible; otherwise, returns false.
← 7 Loading web pages — Table of Contents — 7.3 Origin →