Change Language


Follow Navioo On Twitter

Window : Object

The Window object represents the web browser window. It provides access to objects to use to manipulate the browsing environment and properties for accessing the object model below it.

Platform Support

IE Mozilla Netscape Opera Safari
3.0+ 1.0+ 2.0+ 7.0+ 1.0+

Constructors

Constructor Action IE Mozilla Netscape Opera Safari
Window Constructor() : Window
Creates a new instance of a Window object.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+

Window() : Window

Creates a new instance of a Window object.

Returns

Window
Visibility
internal

Properties

Property Action IE Mozilla Netscape Opera Safari
defaultStatus : String
Gets or sets the default text in the status bar at the bottom of a web browser window.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
See Also

Window.status

Availability

JavaScript 1.0

name : String
Gets or sets the name of a window.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
See Also

Form.target|Link.target

Availability

JavaScript 1.0|read/write in JavaScript 1.1

static onabort : Function
Fires when the loading of the element is cancelled before it finishes loading.
No Details 4.0+ no no no 1.0+
static onafterprint : Function
Fires immediately after a user prints or print previews a document.
No Details 4.0+ no no no no
static onbeforeprint : Function
Fires immediately before a user prints or print previews a document.
No Details 4.0+ no no no no
static onbeforeunload : Function
Fires immediately before a document is unloaded.
No Details 4.0+ no no no no
static onblur : Function
Event handler for blur events on a window.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
See Also

Window.blur|Window.focus|Window.onfocus|Event|EventListener|EventTarget

Availability

HTML DOM Level 0

static onchange : Function
Fires when the value of the element changes.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onclick : Function
Fires when the element is clicked.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onclose : Function
Fires when the user closes the window.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static ondragdrop : Function
Fires when a user drops a file onto the window.
No Details no no 4.0+ no no
static onerror : Function
Event handler for errors raised on a window.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
Availability

JavaScript 1.1|buggy in Netscape 6/6.1

static onfocus : Function
Event handler for focus events on a window.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
See Also

Window.blur|Window.focus|Window.onblur|Event|EventListener|EventTarget

Availability

JavaScript 1.1

static onhelp : Function
Fires when a user presses the F1 key to activate help.
No Details 4.0+ no no no no
static onkeydown : Function
Fires when a user presses down on a key while the element has focus.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onkeypress : Function
Fires when a user presses a key or holds down the key while the element has focus.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onkeyup : Function
Fires when a user releases a key while the element has focus.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onload : Function
Event handler for window loading.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
See Also

Window.onunload|Event|EventListener|EventTarget

Availability

JavaScript 1.0

static onmousedown : Function
Fires when a user clicks down on the mouse button while the element has focus.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onmousemove : Function
Fires when the mouse moves while the pointer over the element.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onmouseout : Function
Fires when the mouse pointer moves off of the element.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onmouseover : Function
Fires when the mouse pointer moves over the element.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onmouseup : Function
Fires when the user releases the mouse button while the element has focus.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onmove : Function
Event handler for window move events.
No Details no 1.0+ 4.0+ 7.0+ 1.0+
static onreset : Function
Fires when the form data is reset.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onresize : Function
Event handler for window resizing.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
Availability

JavaScript 1.2

static onscroll : Function
Fires when a user scrolls the element.
No Details 4.0+ no no no 1.0+
static onselect : Function
Fires when the element is selected.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onsubmit : Function
Fires when the form data is submitted.
No Details 2.0+ 1.0+ 1.0+ 4.0+ 1.0+
static onunload : Function
Event handler for unload events on the window.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
See Also

Window.onload|Event|EventListener|EventTarget

Availability

JavaScript 1.0

status : String
Gets or sets the text in the status bar at the bottom of a web browser window.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
See Also

Window.defaultStatus

Availability

JavaScript 1.0

closed : Boolean
Indicates whether a window is closed or not.
No Details 4.0+ 1.0+ 3.0+ 7.0+ 1.0+
document : Document
Reference to the document that the window contains.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
See Also

Document

event : Event
Instance of an Event that is available to an event handler.
Show Details 4.0+ no no 7.0+ 1.0+
See Also

Event

frames : Array
An array of the frames in the current window.
No Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
history : History
Reference to the History object.
Show Details 3.0+ 1.0+ 3.0+ 7.0+ 1.0+
See Also

History

innerHeight : Number
Height of the active document area of the window.
No Details no 1.0+ 4.0+ 7.0+ 1.0+
innerWidth : Number
Width of the active document area of the window.
No Details no 1.0+ 4.0+ 7.0+ 1.0+
length : Number
Number of frames in the window.
No Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
location : Location
Gets or sets the current URL of a window.
No Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
Math : Math
Reference to an object holding math functions and constants.
Show Details 3.0+ 1.0+ 2.0+ no no
See Also

Math

navigator : Navigator
Reference to the Navigator object.
Show Details 3.0+ 1.0+ 6.0+ 7.0+ 1.0+
See Also

Navigator

opener : Window
Reference to the window that opened the current window.
No Details 3.0+ 1.0+ 3.0+ 7.0+ 1.0+
parent : Window
Reference to the parent of the current window or subframe.
No Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
screen : Screen
Reference to the Screen object associated with the window.
Show Details 4.0+ 1.0+ 6.0+ 7.0+ 1.0+
See Also

Screen

self : Window
Reference to a Window object itself.
No Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
top : Window
Reference to the top window in the window hierarchy.
No Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
window : Window
Reference to the current Window.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+
See Also

Window

XMLHttpRequest : XMLHttpRequest
Reference to an XMLHttpRequest object.
Show Details 5.0+ 1.0+ 7.0+ no 1.2+
See Also

XMLHttpRequest

Availability

HTML DOM Level 3

Functions

Method Action IE Mozilla Netscape Opera Safari
alert() : void
Displays an alert dialogue box.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+

Returns

void
See Also

Window.confirm|Window.prompt

Availability

JavaScript 1.0

back() : void
Moves back one step in the Window history.
Show Details 1.0+ 4.0+ 7.0+ 1.0+

Returns

void
blur() : void
Removes focus from the Window.
Show Details 4.0+ 1.0+ 3.0+ 7.0+ 1.0+

Returns

void
See Also

Window.focus

Availability

JavaScript 1.1

captureEvents(Number eventmask) : void
Sets the Window to capture all events of the specified type.
Show Details no no 4.0+ no no

Parameters

Number eventmask Type of event to capture.

Returns

void
See Also

Event|Window.handleEvent|Window.releaseEvents|Window.routeEvent|EventTarget.addEventListener

clearInterval(Object intervalId) : void
Clears a delay that was set with the setInterval method.
Show Details 4.0+ 1.0+ 4.0+ 7.0+ 1.0+

Parameters

Object intervalId Identifier for the interval.

Returns

void
See Also

Window.setInterval

Availability

HTML DOM Level 0

clearTimeout(Object timeoutId) : void
Clears a timeout that was set with the setTimeout method.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+

Parameters

Object timeoutId Identifier for the timeout.

Returns

void
See Also

Window.setTimeout

Availability

HTML DOM Level 0

close() : void
Closes the current window.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+

Returns

void
See Also

Window.open|the closed and opener properties of Window

Availability

JavaScript 1.0

confirm(String question) : Boolean
Displays a confirmation dialogue box.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+

Parameters

String question Text to display to ask the user a "yes" or "no" question to confirm or cancel.

Returns

Boolean
See Also

Window.alert|Window.prompt

Availability

HTML DOM Level 0

focus() : void
Sets the focus on the current Window.
Show Details 4.0+ 1.0+ 3.0+ 7.0+ 1.0+

Returns

void
See Also

Window.blur

Availability

HTML DOM Level 0

forward() : void
Moves forward one step in the Window history.
Show Details no no 4.0+ 7.0+ no

Returns

void
static getComputedStyle(Element elt, String pseudoElt) : CSSStyleDeclaration
Computes style information and returns the CSSStyleDeclaration for the specified document Element.
Show Details 6.0+ 1.0+ 6.0+ no 1.0+

Parameters

Element elt Document element to get the style information for.
String pseudoElt CSS pseudoelement.

Returns

CSSStyleDeclaration
See Also

CSS2Properties|CSSStyleDeclaration|HTMLElement.style

Availability

HTML DOM Level 2

handleEvent(Object event) : Object
Calls the event handler for the specified event.
Show Details no no 4.0+ no no

Parameters

Object event Event to have the event handler called for.

Returns

Object
See Also

Window.routeEvent

home() : void
Returns the browser Window to the browser home page.
Show Details no no 4.0+ 7.0+ no

Returns

void
Availability

HTML DOM Level 0

moveBy(Number dx, Number dy) : void
Moves a Window by the specified amount.
Show Details 4.0+ 1.0+ 4.0+ 7.0+ 1.0+

Parameters

Number dx Number of pixels to move the window to the right. Use a negative value to move the window to the left.
Number dy Number of pixels to move the window towards the bottom of the screen. Use a negative value to move the window up.

Returns

void
Availability

JavaScript 1.2

moveTo(Object x, Object y) : void
Moves the Window to the specified location.
Show Details 4.0+ 1.0+ 4.0+ 7.0+ 1.0+

Parameters

Object x Number of pixels from the left edge of the screen to set the horizontal position.
Object y Number of pixels from the top edge of the screen to set the vertical position.

Returns

void
Availability

JavaScript 1.2

navigate(String url) : void
Automatically navigates to the specified URL.
Show Details 3.0+ no no no no

Parameters

String url URL to navigate to.

Returns

void
See Also

Location|Window.location

open([String url,] [String name,] [String features,] [Boolean replace]) : Window
Opens a new Window.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+

Parameters

String url (optional)Sets the URL of the new Window.
String name (optional)Sets the name of the new Window.
String features (optional)Comma-separated list of features for the new Window to have.
Boolean replace (optional)Whether or not the URL in the new window should create a new entry in the browser history or replace the current URL.

Returns

Window
See Also

Location.replace|Window.close|the closed and opener properties of Window

Availability

HTML DOM Level 0

print() : void
Prints the contents of the current Window.
Show Details 5.0+ 1.0+ 4.0+ 7.0+ no

Returns

void
Availability

HTML DOM Level 0

prompt(String message, String default) : String|Number
Displays a dialogue box that prompts the user for input.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+

Parameters

String message Text message or question to display to the user.
String default Default value to display in the text field.

Returns

String
Number
See Also

Window.alert|Window.confirm

Availability

HTML DOM Level 0

releaseEvents(Number eventmask) : void
Sets the Window to release all captured events of a specified type.
Show Details no no 4.0+ 7.0+ no

Parameters

Number eventmask Type of event to stop capturing.

Returns

void
See Also

Event|Window.captureEvents|Window.handleEvent|Window.routeEvent|EventTarget.removeEventListener

resizeBy(Number dw, Number dh) : void
Resizes the current window by the specified amount.
Show Details 4.0+ no 4.0+ 7.0+ 1.0+

Parameters

Number dw Number of pixels to resize the window horizontally.
Number dh Number of pixels to resize the window vertically.

Returns

void
Availability

JavaScript 1.2

resizeTo(Object width, Object height) : void
Resizes the current window to the specified size.
Show Details 4.0+ no 4.0+ 7.0+ 1.0+

Parameters

Object width Number of pixels wide that the window should be.
Object height Number of pixels tall that the window should be.

Returns

void
routeEvent(Function event) : Object
Routes a captured event through the event hierarchy.
Show Details no no 4.0+ no no

Parameters

Function event Event to be routed.

Returns

Object
See Also

Window.captureEvents|Window.handleEvent|Window.releaseEvents

scroll(Object x, Object y) : void
Scrolls the window to a specified place in the document.
Show Details 4.0+ 1.0+ 3.0+ no 1.0+

Parameters

Object x Horizontal position (in pixels) to scroll to.
Object y Vertical position (in pixels) to scroll to.

Returns

void
Availability

JavaScript 1.1|deprecated in JavaScript 1.2

scrollBy(Number dx, Number dy) : void
Scrolls the current document in the window by the specified amount.
Show Details 4.0+ 1.0+ 4.0+ 7.0+ 1.0+

Parameters

Number dx Number of pixels to scroll horizontally.
Number dy Number of pixels to scroll vertically.

Returns

void
Availability

JavaScript 1.2

scrollTo(Object x, Object y) : void
Scrolls the window to a specified place in the document.
Show Details 4.0+ 1.0+ 4.0+ 7.0+ 1.0+

Parameters

Object x Horizontal position (in pixels) to scroll to.
Object y Vertical position (in pixels) to scroll to.

Returns

void
Availability

JavaScript 1.2

setInterval(String code, Function func, Number interval, Array args...) : Number
Calls a function or evaluates an expression every time the specified interval elapses.
Show Details 4.0+ 1.0+ 4.0+ 7.0+ 1.0+

Parameters

String code Expression to be evaluated (not required if func is used).
Function func Function to be called (not required if code is used).
Number interval Number of milliseconds to wait.
Array args... (zero-or-more)Arguments (if any) to be taken by the function.

Returns

Number
See Also

Window.clearInterval|Window.setTimeout

Availability

JavaScript 1.2|IE 4 supports only one of the two forms

setTimeout(String code, Function func, String delay, Array args) : Number
Specifies a delay for calling a function or evaluating an expression.
Show Details 3.0+ 1.0+ 2.0+ 7.0+ 1.0+

Parameters

String code Expression to be evaluated (not required if func is used).
Function func Function to be called (not required if code is used).
String delay Number of milliseconds to wait.
Array args Arguments (if any) to be taken by the function.

Returns

Number
See Also

Window.clearTimeout|Window.setInterval

Availability

JavaScript 1.0

stop() : void
Stops the window from loading.
Show Details no no 4.0+ 7.0+ no

Returns

void
Availability

HTML DOM Level 0

References

Document|AbstractView

Availability

JavaScript 1.0|enhanced in JavaScript 1.1 and 1.2

text_javascript Navioo_docs

Examples -> Source code Demo online - > window:

Ajax Javascript feed

↑ Grab this Headline Animator