Window

An instantiation of Window represents a single browser frame (viewport); it may be either a top-level frame (e.g., a tab) or an HTML frame or iframe element. It provides both the global namespace (so its properties usually need not be prefixed by it) and the global scope (so its properties may be accessed from anywhere within it). Note that its otherwise global scope does not apply to other frames.

To prevent XSS attacks, properties of windows from one domain cannot be accessed by scripts from another.

When the current scope contains a of a Window property, the Window property is hidden. To avoid this, always reference Window properties (except  or  ), for example , as either   or.

closed
Indicates whether the user has closed this window; useful in the context of popups, which exist independent from other windows.

document
The page which this window is displaying.

frames
A list of all  and   elements which this window contains.

history
Exposes methods which allow navigation through the history of the current session (i.e., tab or frame).

location
Stores and changes the current URL and its components.

name
The window's name, as passed to.

opener
In Mozilla, a reference to the window whose open method initialized this window, if any ( otherwise). In Internet Explorer, a  value which may be set by scripts. (Microsoft says it is only available to and  pages, but does not specify what it is in others.)

parent
If the current window is contained in another, this is the container. Otherwise, this is equal to window.

self
The less common of window.

status
The text in the status bar. Both Mozilla-based browsers and Internet Explorer provide the option to disable it; Mozilla disables it by default.

top
The top-level or "root" window (may also be the current window).

window
Points to its owner, i.e. .  See the top of this page.

alert
Displays message in a dialog window with an OK button.

Go here to see a real alert box.

message
Something you want to tell the user.

blur
Removes focus from this window.

clearInterval
Cancels the identified interval.

interval
A number corresponding to the scheduled interval which is to be canceled.

close
Closes this script-generated window. If the window was not generated by a script, one of the following occurs:
 * If the browser is Mozilla, an error occurs.
 * If the browser is Internet Explorer, the user is presented with a confirm dialog according to which the page will be closed or preserved.

confirm
Displays message in a dialog window with Cancel and OK buttons; returns a value which represents whether the user clicked OK.

Go here to see the confirm box.

message
A yes-or-no question, usually of the form, "Do you really want to [...]?" In many cases, an undo mechanism is more appropriate.

open
Requests url in the window (or tab) identified by name; if necessary, makes such a window first.

url
A URL which defaults to the empty string. The empty string opens a blank page.

name
Optional. The window's name; corresponds to the HTML attribute; defaults to. For the relevant naming rules, see HTML 4.01 §6.16 Frame target names. For how the browser is to behave in relation to the name, see §B.8 Notes on frames and §16.3.2 Target semantics.

features
Optional.

replace
Optional. If, causes Microsoft Internet Explorer to overwrite the current page's history item with the given url. Only applies when name refers to the current window.

prompt
Displays message in a dialog window with Cancel and OK buttons, and a text input; returns the value in the text input when the user clicks OK, or  if the user clicks Cancel.

message
A question which typically requires a detailed answer.

default
Optional; if passed, used as the text input's initial value.

scroll
Scrolls to a particular set of coordinates in the document.

scrollBy
Scrolls the document in the window by the given amount.

scrollTo
Scrolls to a particular set of coordinates in the document.

setInterval
Executes the given code every msDelay milliseconds; returns a unique integer which, when passed to clearInterval, will cancel the interval.

code
Either a function to be called or a string to be evaluated. As with eval, best practices recommend a function over a string.

msDelay
A number of milliseconds by which each execution of the given code is to be delayed.