Mozilla XUL Element and Script Reference

Contents  Quick Reference

XUL Window

The global window object. It has all the properties as the window object for HTML documents, although some properties are not used for anything.

Properties and Methods:

Components

An object that can be used to get XPCOM components and interfaces.

alert ( text )

Displays a popup window with the specified text in it. The user can press the OK button to close the window. This is usually used for error messages.

arguments

For a window opened with openDialog, the arguments property is an array of the additional parameters after the first three in the openDialog function.

blur ( )

Removes the focus from the window.

captureEvents

clearInterval ( id )

Removes the interval specified by the given identifier id.

clearTimeout ( id )

Removes the timeout specified by the given identifier id.

close ( )

Closes the window.

closed

Set to the true if the window has been closed.

confirm ( text )

Displays the specified text to the user in a popup box, along with OK and Cancel buttons. If the user presses OK, true is returned. If the user presses Cancel, false is returned.

controllers

disableExternalCapture

document

Refers to the document object for the file currently displayed in the window.

dump ( text )

Prints the specified text to the console. This function is commonly used for debugging.

enableExternalCapture

escape ( text )

Returns the text escaped so that is can be part of a URL.

focus ( )

Assigns the focus to the window.

frames

An array of the iframe elements contained in the window.

getComputedStyle ( element , pseudo )

Returns the values of the style properties as currently displayed to the user. This is the method you would use to get, for example, the current width and height of the element as it is drawn on the window. The pseudo argument is used to get a pseudo-style of an element, for example to get the style of the 'hover' of an element.

history

Refers to the history for the window.

innerHeight

The height of the inner part of the window. This refers to the window size minus the size of the title bar and frame.

innerWidth

The width of the inner part of the window. This refers to the window size minus the size of the title bar and frame.

length

The number of frames contained in the window, or the length of the frames array.

moveBy ( x , y )

Moves the position of the window on the screen by the given x and y position relative to its current position.

moveTo ( x , y )

Moves the position of the window on the screen to the given x and y position.

name

The name of the window as was specified by the second argument to the window.open function that opened the window.

navigator

Refers to the global navigator object.

open ( url, name, flags)

Opens a new window containing the contents of the specified url. If the document is a XUL file, you should specify the 'chrome' flag in the flags parameter. This will cause the window to be opened as a chrome. Otherwise, the file will opened as a document and chrome will be supplied around it (typically a browser window). The second argument is a window name which can be used to find the window. Numerous flags are available, some of which are documented here. Additional arguments are passed to the window and are available in its argument array.

openDialog ( url, name, flags, ... )

Opens a new dialog box containing the contents of the specified url. This is similar to the open method except that some platforms may treat the window differently. For example, it may appear differently or be modal. This function can take additional arguments after the first three which are placed in the new window's arguments property.

opener

Refers to the window object that opened this window.

outerHeight

The height of the outer part of the window. This refers to the window size including the size of the title bar and frame.

outerWidth

The width of the outer part of the window. This refers to the window size including the size of the title bar and frame.

pageXOffset
pageYOffset
parent

The parent window of this window.

prompt ( text, default )

Displays a popup window with a textbox in it. The argument text is displayed to the user above the textbox. The second argument can be used to specify a default value for the textbox. If the user enters text and presses OK, the text is returned from the function. If the user presses Cancel, null is returned.

releaseEvents

resizeBy ( width, height )

Changes the size of the window by the given width and height relative to its current size.

resizeTo ( width , height )

Changes the size of the window to the given width and height. The position of the window can be changed with moveTo. If you make it too small, it will disappear from the screen.

routeEvent

screen

The global screen object which contains information about the user's display.

screenX

The horizontal position of the window on the screen.

screenY

The vertical position of the window on the screen.

scroll

scrollBy

scrollTo

scrollX

If the content of the window is too large to fit within the window frame, scroll bars can optionally appear. This property is used to determine the horizontal scroll position.

scrollY

If the content of the window is too large to fit within the window frame, scroll bars can optionally appear. This property is used to determine the vertical scroll position.

self

Refers to the window itself.

setCursor ( cursorname )

Can be used to change the mouse cursor that is used while over the window. The argument is the name of the cursor to use. The cursor change will stay until you change it back (by setting the cursor to 'auto').

A number of cursors are available, some of which might not be available on all platforms.

auto, default, pointer, crosshair, move, text, wait, help, n-resize, s-resize, w-resize, e-resize, ne-resize, nw-resize, se-resize, sw-resize, copy, alias, context-menu, cell, grab, grabbing, spinning, count-up, count-down, count-up-down

setInterval ( code, time )

Evaluates a string of code repeatedly. The argument time is used to specify the interval between evaluations, measured in milliseconds. This function returns an identifier which can be passed to clearInterval.

setTimeout ( code, time )

Evaluates a string of code after a certain amount of time has passed. The time is measured in milliseconds so use a value of 1000 for one second. If you want to have something every second (or some other time) use setInterval. This function returns an identifier which can be passed to clearTimeout.

sizeToContent ( )

Changes the size of the window so that it is just large enough to hold its content.

top

Refers to the topmost window. This is used to get the outer window from a document that is contained within an iframe.

unescape ( text )

Returns the text that has been URL-escaped.

updateCommands

window

Refers to the window itself.