About this specification

This specification is like no other — it has been processed with you, the humble web developer, in mind.

The focus of this specification is readability and ease of access. Unlike the full HTML Standard, this "developer's edition" removes information that only browser vendors need know. It is automatically produced from the full specification by our build tooling, and thus always in sync with the latest developments in HTML.

To read about its conception, construction, and future, read the original press release, and the blog post about its relaunch.

Finally, feel free to contribute on GitHub to make this edition better for everyone!

    1. 7.2 The Window object
      1. 7.2.1 APIs for creating and navigating browsing contexts by name
      2. 7.2.2 Accessing other browsing contexts
      3. 7.2.3 Named access on the Window object
      4. 7.2.4 Closing browsing contexts
      5. 7.2.5 Browser interface elements

7.2 The Window object

window . window
window . frames
window . self

These attributes all return window.

window . document

Returns the Document associated with window.

document . defaultView

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 ] ] ] )

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 ]

Returns the name of the window.

Can be set, to change the name.

window . close()

Closes the window.

window . closed

Returns true if the window has been closed, false otherwise.

window . stop()

Cancels the document load.

7.2.2 Accessing other browsing contexts

window . length

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:

  1. Prompt to unload browsingContext's active document. If the user refused to allow the document to be unloaded, then return.

  2. Unload browsingContext's active document with the recycle parameter set to false.

  3. Remove browsingContext from the user interface (e.g., close or hide its tab in a tabbed browser).

  4. 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

Returns true if the location bar is visible; otherwise, returns false.

window . menubar . visible

Returns true if the menu bar is visible; otherwise, returns false.

window . personalbar . visible

Returns true if the personal bar is visible; otherwise, returns false.

window . scrollbars . visible

Returns true if the scroll bars are visible; otherwise, returns false.

window . statusbar . visible

Returns true if the status bar is visible; otherwise, returns false.

window . toolbar . visible

Returns true if the toolbar is visible; otherwise, returns false.