This is a snapshot of an early working draft and has therefore been superseded by the HTML standard.

This document will not be further updated.


Call For Comments — 27 October 2007

4.2. The default view

The AbstractView object of default views must also implement the Window object.

interface Window {
  // the current browsing context
  readonly attribute Window window;
  readonly attribute Window self;
           attribute DOMString name;
  readonly attribute Location location;
  readonly attribute History history;
  readonly attribute UndoManager undoManager;
  Selection getSelection();

  // the user agent
  readonly attribute ClientInformation navigator; 
  readonly attribute Storage sessionStorage;
  readonly attribute StorageList globalStorage;
  Database openDatabase(in DOMString name, in DOMString version, in DOMString displayName, in unsigned long estimatedSize);

  // modal user prompts
  void alert(in DOMString message);
  boolean confirm(in DOMString message);
  DOMString prompt(in DOMString message);
  DOMString prompt(in DOMString message, in DOMString default);
  void print();

  // other browsing contexts
  readonly attribute Window frames;
  readonly attribute unsigned long length;
  readonly attribute Window opener;
  Window open();
  Window open(in DOMString url);
  Window open(in DOMString url, in DOMString target);
  Window open(in DOMString url, in DOMString target, in DOMString features);
  Window open(in DOMString url, in DOMString target, in DOMString features, in DOMString replace);

  // cross-document messaging
  void postMessage(in DOMString message);

  // event handler DOM attributes
           attribute EventListener onabort;
           attribute EventListener onbeforeunload;
           attribute EventListener onblur;
           attribute EventListener onchange;
           attribute EventListener onclick;
           attribute EventListener oncontextmenu;
           attribute EventListener ondblclick;
           attribute EventListener ondrag;
           attribute EventListener ondragend;
           attribute EventListener ondragenter;
           attribute EventListener ondragleave;
           attribute EventListener ondragover;
           attribute EventListener ondragstart;
           attribute EventListener ondrop;
           attribute EventListener onerror;
           attribute EventListener onfocus;
           attribute EventListener onkeydown;
           attribute EventListener onkeypress;
           attribute EventListener onkeyup;
           attribute EventListener onload;
           attribute EventListener onmessage;
           attribute EventListener onmousedown;
           attribute EventListener onmousemove;
           attribute EventListener onmouseout;
           attribute EventListener onmouseover;
           attribute EventListener onmouseup;
           attribute EventListener onmousewheel;
           attribute EventListener onresize;
           attribute EventListener onscroll;
           attribute EventListener onselect;
           attribute EventListener onsubmit;
           attribute EventListener onunload;

The window, frames, and self DOM attributes must all return the Window object itself.

The Window object also provides the scope for script execution. Each Document in a browsing context has an associated list of added properties which, when a document is active, are available on the Document's default view Window object. A Document object's list of added properties must be empty when the Document object is created.

Objects implementing the Window interface must also implement the EventTarget interface.

Window objects also have an implicit [[Get]] method which returns nested browsing contexts.

4.2.1. Security

User agents must raise a security exception whenever any of the members of a Window object are accessed by scripts whose origin is not the same as the Window object's browsing context's active document's origin, with the following exceptions:

User agents must not allow scripts to override the location object's setter.

4.2.2. Constructors

All Window objects must provide the following constructors:


When invoked as constructors, these must return a new HTMLAudioElement object (a new audio element). If the src argument is present, the object created must have its src content attribute set to the provided value, and the user agent must invoke the load() method on the object before returning.

Image(in unsigned long w)
Image(in unsigned long w, in unsigned long h)

When invoked as corstructors, these must return a new HTMLImageElement object (a new img element). If the h argument is present, the new object's height content attribute must be set to h. If the w argument is present, the new object's width content attribute must be set to w.

Option(in DOMString name)
Option(in DOMString name, in DOMString value)

When invoked as constructors, these must return a new HTMLOptionElement object (a new option element). need to define argument processing

And when constructors are invoked but without using the constructor syntax...?

4.2.3. APIs for creating and navigating browsing contexts by name

The open() method on Window objects provides a mechanism for navigating an existing browsing context or opening and navigating an auxiliary browsing context.

The method has four arguments, though they are all optional.

The first argument, url, gives a URI (or IRI) for a page to load in the browsing context. If no arguments are provided, then the url argument defaults to "about:blank". The argument must be resolved to an absolute URI by ...

The second argument, target, specifies the name of the browsing context that is to be navigated. It must be a valid browsing context name. If fewer than two arguments are provided, then the name argument defaults to the value "_blank".

The third argument, features, has no effect and is supported for historical reasons only.

The fourth argument, replace, specifies whether or not the new page will replace the page currently loaded in the browsing context, when target identifies an existing browsing context (as opposed to leaving the current page in the browsing context's session history). When three or fewer arguments are provided, replace defaults to false.

When the method is invoked, the user agent must first select a browsing context to navigate by applying the rules for chosing a browsing context given a browsing context name using the target argument as the name and the browsing context of the script as the context in which the algorithm is executed, unless the user has indicated a preference, in which case the browsing context to navigate may instead be the one indicated by the user.

For example, suppose there is a user agent that supports control-clicking a link to open it in a new tab. If a user clicks in that user agent on an element whose onclick handler uses the API to open a page in an iframe, but, while doing so, holds the control key down, the user agent could override the selection of the target browsing context to instead target a new tab.

Then, the user agent must navigate the selected browsing context to the URI given in url. If the replace is true, then replacement must be enabled; otherwise, it must not be enabled unless the browsing context was just created as part of the the rules for chosing a browsing context given a browsing context name.

The method must return the Window object of the default view of the browsing context that was navigated, or null if no browsing context was navigated.

The name attribute of the Window object must, on getting, return the current name of the browsing context, and, on setting, set the name of the browsing context to the new value.

The name gets reset when the browsing context is navigated to another domain.

4.2.4. Accessing other browsing contexts

In ECMAScript implementations, objects that implement the Window interface must have a [[Get]] method that, when invoked with a property name that is a number i, returns the ith child browsing context of the active Document, sorted in document order of the elements nesting those browsing contexts.

The length DOM attribute on the Window interface must return the number of child browsing contexts of the active Document.