The Window object defines the following properties.
Non-portable, browser-specific properties are listed separately after this list.
Note that the Window object is the Global object for client-side JavaScript;
therefore the Window object also has the properties listed on the Global
reference page.
- closed
-
A read-only boolean value that specifies whether the
window has been closed.
- defaultStatus
-
A read/write string that specifies a persistent message
to appear in the status line whenever the browser is not displaying another
message.
- document
-
A read-only reference to the Document object contained in
this window or frame. See Document.
- frames[ ]
-
An array of Window objects, one for each frame contained
within the this window. Note that frames referenced by the frames[ ]
array may themselves contain frames and may have a frames[ ] array
of their own.
- history
-
A read-only reference to the History object of this
window or frame. See History.
- length
-
Specifies the number of frames contained in this window
or frame. Same as frames.length.
- location
-
The Location object for this window or frame. See
Location. This property has special behavior: if you assign a URL string to
it, the browser loads and displays that URL.
- name
-
A string that contains the name of the window or frame.
The name is specified with the Window.open( ) method, or with the name
attribute of a <frame> tag. Read-only in JS 1.0; read/write
in JS 1.1.
- navigator
-
A read-only reference to the Navigator object, which
provides version and configuration information about the web browser. See
Navigator.
- opener
-
A read/write reference to the Window that opened this
window. JS 1.1.
- parent
-
A read-only reference to the Window object that contains
this window or frame. If this window is a top-level window, parent
refers to the window itself.
- screen
-
A read-only reference to the Screen object that specifies
information about the screen the browser is running on. See Screen. JS 1.2.
- self
-
A read-only reference to this window itself. This is a
synonym for the window property.
- status
-
A read/write string that can be set to display a
transient message in the browser's status line.
- top
-
A read-only reference to the the top-level window that
contains this window. If this window is a top-level window, top
refers to the window itself.
- window
-
The window property is identical to the self
property; it contains a reference to this window.
- innerHeight, innerWidth
-
Read/write properties that specify the height and width,
in pixels, of the document display area of this window. These dimensions do
not include the height of the menubar, toolbars, scrollbars, and so on.
- outerHeight, outerWidth
-
Read/write integers that specify the total height and
width, in pixels, of the window. These dimensions include the height and
width of the menubar, toolbars, scrollbars, window borders, and so on.
- pageXOffset, pageYOffset
-
Read-only integers that specify the number of pixels that
the current document has been scrolled to the right (pageXOffset)
and down (pageYOffset).
- screenX, screenY
-
Read-only integers that specify the X and Y-coordinates
of the upper-left corner of the window on the screen. If this window is a
frame, these properties specify the X and Y-coordinates of the top-level
window that contains the frame.
The Window object has the following portable methods. Since
the Window object is the Global object in client-side JavaScript, it also
defines the methods listed on the Global reference page.
- alert( message)
-
Displays message in a dialog box. Returns
nothing. JS 1.0.
- blur( )
-
Yields the keyboard focus and returns nothing. JS 1.1.
- clearInterval( intervalId)
-
Cancels the periodic execution of code specified by intervalId.
See setInterval( ). Returns nothing. JS 1.2.
- clearTimeout( timeoutId)
-
Cancels the pending timeout specified by timeoutId.
See setTimeout( ). Returns nothing. JS 1.0.
- close( )
-
Closes a window and returns nothing. JS 1.0.
- confirm( question)
-
Displays question in a dialog box and
waits for a yes-or-no response. Returns true if the user clicks the
OK button, or false if the user
clicks the Cancel button. JS 1.0.
- focus( )
-
Requests keyboard focus; this also brings the window to
the front on most platforms. Returns nothing. JS 1.1.
- getComputedStyle(
elt)
-
Returns a read-only Style object that contains all CSS
styles (not just inline styles) that apply to the specified document element
elt. Positioning attributes such as left, top,
and width queried from this computed style object are always
returned as pixel values. DOM Level 2.
- moveBy( dx,
dy)
-
Moves the window the specified distances from its current
position and returns nothing. JS 1.2.
- moveTo( x,
y)
-
Moves the window to the specified position and returns
nothing. JS 1.2
- open( url,
name, features)
-
Displays the specified url in the named
window. If the name argument is omitted or if there is no
window by that name, a new window is created. The optional features
argument is a string that specifies the size and decorations of the new
window as a comma-separated list of features. Feature names commonly
supported on all platforms are: width=pixels, height=pixels,
location, menubar, resizable, status,
and toolbar. In IE, set the position of the window with left=x
and top=y. In Netscape, use screenX=x and screenY=y.
Returns the existing or new Window object. JS 1.0.
- print( )
-
Simulates a click on the browser's Print
button and returns nothing. Netscape 4; IE 5.
- prompt( message,
default)
-
Displays message in a dialog box and
waits for the user to enter a text response. Displays the optional default
as the default response. Returns the string entered by the user, or the
empty string if the user did not enter a string, or null if the
user clicked Cancel. JS 1.0.
- resizeBy( dw,
dh)
-
Resizes the window by the specified amount and returns
nothing. JS 1.2.
- resizeTo( width,
height)
-
Resizes the window to the specified size and returns
nothing. JS 1.2.
- scroll( x,
y)
-
Scrolls the window to the specified coordinates and
returns nothing. JS 1.1; deprecated in JS 1.2 in favor of scrollTo( ).
- scrollBy( dx,
dy)
-
Scrolls the window by a specified amount and returns
nothing. JS 1.2.
- scrollTo( x,
y)
-
Scrolls the window to a specified position and returns
nothing. JS 1.2.
- setInterval( code,
interval, args...)
-
Evaluates the string of JavaScript code
every interval milliseconds. In Netscape 4 and IE 5, code
may be a reference to a function instead of a string. In that case, the
function is invoked every interval milliseconds. In
Netscape, any arguments after interval are passed to the
function when it is invoked, but this feature is not supported by IE.
Returns an interval ID value that can be passed to clearInterval( )
to cancel the periodic executions. JS 1.2.
- setTimeout( code,
delay)
-
Evaluates the JavaScript code in the string code
after delay milliseconds have elapsed. In Netscape 4 and
IE5, code may be a function rather than a string; see the
discussion under setInterval( ). Returns a timeout ID value that
can be passed to clearTimeout( ) to cancel the pending execution of
code. Note that this method returns immediately; it does not
wait for delay milliseconds before returning. JS 1.0.