Fandom

JavaScript Wiki

Window

87pages on
this wiki
Add New Page
Talk0 Share
Line of inheritance:
ObjectAbstractViewWindow

An instance 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 homonym of a Window property, the Window property is hidden. To avoid this, always reference Window properties (except window or self), for example alert, as either window.alert or self.alert.


W3C Mozilla Microsoft
[1] [2] [3]


PropertiesEdit

closedEdit

Data type boolean
Standard none
Documentation Mozilla, Microsoft

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

documentEdit

Data type HTMLDocument
Standard none
Documentation Mozilla, Microsoft

The page which this window is displaying.

framesEdit

Data type HTMLCollection
Standard none
Documentation Mozilla, Microsoft

A list of all frame and iframe elements which this window contains.

historyEdit

Data type History
Standard none
Documentation Mozilla, Microsoft

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

locationEdit

Data type Location
Standard none
Documentation Mozilla, Microsoft

Stores and changes the current URL and its components.

nameEdit

Data type string
Standard none
Documentation Mozilla, Microsoft

The window's name, as passed to Window.open.

openerEdit

Data type Window
Standard none
Documentation Mozilla, Microsoft

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

parentEdit

Data type Window
Standard none
Documentation Mozilla, Microsoft

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

selfEdit

Data type Window
Standard Window Object 1.0
Documentation Mozilla, Microsoft

The less common synonym of window.

statusEdit

Data type string
Standard none
Documentation Mozilla, Microsoft

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

topEdit

Data type Window
Standard none
Documentation Mozilla, Microsoft

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

windowEdit

Data type Window
Standard Window Object 1.0
Documentation Mozilla, Microsoft

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

MethodsEdit

alertEdit

Data type function
Return type undefined
Parameter list message (string)
Standard none
Documentation Mozilla, Microsoft

Displays message in a dialog window with an OK button.

Go here to see a real alert box.

messageEdit

Something you want to tell the user.

blurEdit

Data type function
Return type undefined
Parameter list none
Standard none
Documentation Mozilla, Microsoft

Removes focus from this window.

clearIntervalEdit

Data type function
Return type undefined
Parameter list interval (number)
Standard none
Documentation Mozilla, Microsoft

Cancels the identified interval.

intervalEdit

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

closeEdit

Data type function
Return type undefined
Parameter list none
Standard none
Documentation Mozilla, Microsoft

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.

confirmEdit

Data type function
Return type boolean
Parameter list message (string)
Standard none
Documentation Mozilla, Microsoft

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.

messageEdit

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

openEdit

Data type function
Return type boolean
Parameter list url (string), [name (string)], [features (string)], [replace (boolean)]
Standard none
Documentation Mozilla, Microsoft

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

urlEdit

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

nameEdit

Optional. The window's name; corresponds to the HTML target attribute; defaults to "_blank". 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.

featuresEdit

Optional.

replaceEdit

Optional. If true, 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.

promptEdit

Data type function
Return type string
Parameter list message (string), default (string)
Standard none
Documentation Mozilla, Microsoft

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 null if the user clicks Cancel.

messageEdit

A question which typically requires a detailed answer.

defaultEdit

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

scrollEdit

Data type function
Return type undefined
Parameter list x (number), y (number)
Standard none
Documentation Mozilla, Microsoft

Scrolls to a particular set of coordinates in the document.

scrollByEdit

Data type function
Return type undefined
Parameter list x (number), y (number)
Standard none
Documentation Mozilla, Microsoft

Scrolls the document in the window by the given amount.

scrollToEdit

Data type function
Return type undefined
Parameter list x (number), y (number)
Standard none
Documentation Mozilla, Microsoft

Scrolls to a particular set of coordinates in the document.

setIntervalEdit

Data type function
Return type number
Parameter list code (function or string), msDelay (number)
Standard none
Documentation Mozilla, Microsoft

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

codeEdit

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

msDelayEdit

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

ReferencesEdit

Ad blocker interference detected!


Wikia is a free-to-use site that makes money from advertising. We have a modified experience for viewers using ad blockers

Wikia is not accessible if you’ve made further modifications. Remove the custom ad blocker rule(s) and the page will load as expected.