Window

This object is available to unprivileged JavaScript. It implements the following interfaces:

Properties

readonly boolean closed

readonly Window content

readonly XULControllers controllers

readonly nsIDOMCrypto crypto

String defaultStatus

readonly BarProp directories

readonly Document document

Accessor for the document in this window.

readonly Element frameElement

readonly WindowCollection frames

Accessor for the child windows in this window.

boolean fullScreen

readonly History history

PRInt32 innerHeight

PRInt32 innerWidth

readonly int length

readonly Location location

readonly BarProp locationbar

readonly BarProp menubar

String name

Set/Get the name of this window.

This attribute is "replaceable" in JavaScript

readonly Navigator navigator

nsIDOMWindowInternal opener

PRInt32 outerHeight

PRInt32 outerWidth

readonly PRInt32 pageXOffset

readonly PRInt32 pageYOffset

readonly Window parent

Accessor for this window's parent window, or the window itself if there is no parent, or if the parent is of different type (i.e. this does not cross chrome-content boundaries).

readonly BarProp personalbar

readonly nsIDOMPkcs11 pkcs11

readonly nsIPrompt prompter

readonly Screen screen

PRInt32 screenX

PRInt32 screenY

readonly BarProp scrollbars

Accessor for the object that controls whether or not scrollbars are shown in this window.

This attribute is "replaceable" in JavaScript

readonly PRInt32 scrollMaxX

readonly PRInt32 scrollMaxY

readonly PRInt32 scrollX

Accessor for the current x scroll position in this window in pixels.

This attribute is "replaceable" in JavaScript

readonly PRInt32 scrollY

Accessor for the current y scroll position in this window in pixels.

This attribute is "replaceable" in JavaScript

readonly nsIDOMWindowInternal self

String status

readonly BarProp statusbar

float textZoom

Set/Get the document scale factor as a multiplier on the default size. When setting this attribute, a NS_ERROR_NOT_IMPLEMENTED error may be returned by implementations not supporting zoom. Implementations not supporting zoom should return 1.0 all the time for the Get operation. 1.0 is equals normal size, i.e. no zoom.

readonly BarProp toolbar

readonly Window top

Accessor for the root of this hierarchy of windows. This root may be the window itself if there is no parent, or if the parent is of different type (i.e. this does not cross chrome-content boundaries).

readonly nsIDOMWindowInternal window

readonly EventTarget windowRoot

Get the window root for this window. This is useful for hooking up event listeners to this window and every other window nested in the window root.


Methods

void addEventListener ( String type , EventListener listener , boolean useCapture ) void alert ( String text ) String atob ( String asciiString ) void back ( ) void blur ( ) String btoa ( String base64Data ) void captureEvents ( PRInt32 eventFlags ) void clearInterval ( ) void clearTimeout ( ) void close ( ) boolean confirm ( String text ) void disableExternalCapture ( ) boolean dispatchEvent ( Event evt ) void dump ( String str ) void enableExternalCapture ( ) [noscript] boolean find ( String str , boolean caseSensitive , boolean backwards , boolean wrapAround , boolean wholeWord , boolean searchInFrames , boolean showDialog ) void focus ( ) void forward ( ) CSSStyleDeclaration getComputedStyle ( Element elt , String pseudoElt ) nsISelection getSelection ( ) void home ( ) void moveBy ( PRInt32 xDif , PRInt32 yDif ) void moveTo ( PRInt32 xPos , PRInt32 yPos ) [noscript] Window open ( String url , String name , String options ) [noscript] Window openDialog ( String url , String name , String options , nsISupports extraArgument ) void print ( ) String prompt ( String message , String initial , String title , int savePassword ) void releaseEvents ( PRInt32 eventFlags ) void removeEventListener ( String type , EventListener listener , boolean useCapture ) void resizeBy ( PRInt32 widthDif , PRInt32 heightDif ) void resizeTo ( PRInt32 width , PRInt32 height ) void routeEvent ( Event evt ) void scroll ( PRInt32 xScroll , PRInt32 yScroll ) void scrollBy ( PRInt32 xScrollDif , PRInt32 yScrollDif ) void scrollByLines ( PRInt32 numLines ) void scrollByPages ( PRInt32 numPages ) void scrollTo ( PRInt32 xScroll , PRInt32 yScroll ) PRInt32 setInterval ( ) void setResizable ( boolean resizable ) PRInt32 setTimeout ( ) void sizeToContent ( ) void stop ( ) void updateCommands ( String action )

void addEventListener ( String type , EventListener listener , boolean useCapture )

This method allows the registration of event listeners on the event target. If an EventListener is added to an EventTarget while it is processing an event, it will not be triggered by the current actions but may be triggered during a later stage of event flow, such as the bubbling phase.

If multiple identical EventListeners are registered on the same EventTarget with the same parameters the duplicate instances are discarded. They do not cause the EventListener to be called twice and since they are discarded they do not need to be removed with the removeEventListener method.

Arguments:
type: The event type for which the user is registering
listener: The listener parameter takes an interface implemented by the user which contains the methods to be called when the event occurs.
useCapture: If true, useCapture indicates that the user wishes to initiate capture. After initiating capture, all events of the specified type will be dispatched to the registered EventListener before being dispatched to any EventTargets beneath them in the tree. Events which are bubbling upward through the tree will not trigger an EventListener designated to use capture.

void alert ( String text )

Arguments:
text

String atob ( String asciiString )

Arguments:
asciiString

void back ( )


void blur ( )


String btoa ( String base64Data )

Arguments:
base64Data

void captureEvents ( PRInt32 eventFlags )

Arguments:
eventFlags

void clearInterval ( )


void clearTimeout ( )

These methods take one optional argument that's the timer ID to clear. Often in existing code these methods are passed undefined, which is a nop so we need to support that as well.


void close ( )


boolean confirm ( String text )

Arguments:
text

void disableExternalCapture ( )


boolean dispatchEvent ( Event evt )

This method allows the dispatch of events into the implementations event model. Events dispatched in this manner will have the same capturing and bubbling behavior as events dispatched directly by the implementation. The target of the event is the EventTarget on which dispatchEvent is called.

Arguments:
evt: Specifies the event type, behavior, and contextual information to be used in processing the event.
Returns:
Indicates whether any of the listeners which handled the event called preventDefault. If preventDefault was called the value is false, else the value is true.

void dump ( String str )

Arguments:
str

void enableExternalCapture ( )


boolean find ( String str , boolean caseSensitive , boolean backwards , boolean wrapAround , boolean wholeWord , boolean searchInFrames , boolean showDialog )

Arguments:
str
caseSensitive
backwards
wrapAround
wholeWord
searchInFrames
showDialog

void focus ( )


void forward ( )


CSSStyleDeclaration getComputedStyle ( Element elt , String pseudoElt )

Arguments:
elt
pseudoElt

nsISelection getSelection ( )

Method for accessing this window's selection object.


void home ( )


void moveBy ( PRInt32 xDif , PRInt32 yDif )

Arguments:
xDif
yDif

void moveTo ( PRInt32 xPos , PRInt32 yPos )

Arguments:
xPos
yPos

Window open ( String url , String name , String options )

Arguments:
url
name
options

Window openDialog ( String url , String name , String options , nsISupports extraArgument )

Arguments:
url
name
options
extraArgument

void print ( )


String prompt ( String message , String initial , String title , int savePassword )

Arguments:
message
initial
title
savePassword

void releaseEvents ( PRInt32 eventFlags )

Arguments:
eventFlags

void removeEventListener ( String type , EventListener listener , boolean useCapture )

This method allows the removal of event listeners from the event target. If an EventListener is removed from an EventTarget while it is processing an event, it will not be triggered by the current actions. EventListeners can never be invoked after being removed. Calling removeEventListener with arguments which do not identify any currently registered EventListener on the EventTarget has no effect.

Arguments:
type: Specifies the event type of the EventListener being removed.
listener: The EventListener parameter indicates the EventListener to be removed.
useCapture: Specifies whether the EventListener being removed was registered as a capturing listener or not. If a listener was registered twice, one with capture and one without, each must be removed separately. Removal of a capturing listener does not affect a non-capturing version of the same listener, and vice versa.

void resizeBy ( PRInt32 widthDif , PRInt32 heightDif )

Arguments:
widthDif
heightDif

void resizeTo ( PRInt32 width , PRInt32 height )

Arguments:
width
height

void routeEvent ( Event evt )

Arguments:
evt

void scroll ( PRInt32 xScroll , PRInt32 yScroll )

Arguments:
xScroll
yScroll

void scrollBy ( PRInt32 xScrollDif , PRInt32 yScrollDif )

Method for scrolling this window to a pixel offset relative to the current scroll position.

Arguments:
xScrollDif
yScrollDif

void scrollByLines ( PRInt32 numLines )

Method for scrolling this window by a number of lines.

Arguments:
numLines

void scrollByPages ( PRInt32 numPages )

Method for scrolling this window by a number of pages.

Arguments:
numPages

void scrollTo ( PRInt32 xScroll , PRInt32 yScroll )

Method for scrolling this window to an absolute pixel offset.

Arguments:
xScroll
yScroll

PRInt32 setInterval ( )


void setResizable ( boolean resizable )

Arguments:
resizable

PRInt32 setTimeout ( )

These methods take typeless arguments and optional arguments, the first argument is either a function or a string, the second argument must be a number (ms) and the rest of the arguments (2 ... n) are passed to the callback function


void sizeToContent ( )

Method for sizing this window to the content in the window.


void stop ( )


void updateCommands ( String action )

Arguments:
action

Reference documentation is generated from Mozilla's source.

Add a note User Contributed Notes
No comments available

Copyright © 1999 - 2005 XULPlanet.com