Window Opening Functions - Usage

window.js defines the following functions:

Window Opening

openCenteredOnOpenerWindow()

Synopsis

openCenteredOnOpenerWindow(url, name, width, height, status, scrollbars, moreProperties, openerName)

Arguments

url

The url of the document that should appear in the new window as soon as it is created.

name

The HTML name to be given to the window. This name may contain only letters, numbers and underscores. This name can be used to target links into the new window using the target attribute of the <a href> tag.

width

The interior width of the new window (the full width, including the window edge, will be bigger).

height

The interior height of the new window (the full height, including the window edge, titlebar and status bar, will be bigger).

status

An optional argument that specifies whether the new window should have a status bar at the bottom. Any non-empty (such as true) will indicate that a status bar is required.

scrollbars

An optional argument that specifies whether the new window should have scrollbars. Any non-empty value (such as true) will indicate that scrollbars are required.

moreProperties*

An optional argument that specifies properties (other than a status bar and scrollbars) that may be added to the window. This should be a quoted, comma-separated list of property names. Valid property names are limited to those acceptable in the 3rd argument to the window.open() method.

openerName

An optional HTML name to be given to the opener window (the window containing the script). This name may contain only letters, numbers and underscores. This allows links in the new window to target the opener window using the target attribute of the <a href> tag.

Returns

A reference to the new window. This reference can be used to manipulate the new window after it has been created.

Description

openCenteredOnOpenerWindow() creates a new window of given dimensions centered with respect to the opener window. The positioning is slightly different in different browsers - in NS4+ and Mozilla, the centering is with respect to the whole browser window; in IE, the centering is with respect to the document area of the browser window. In browsers where the new window can't be centered on the opener window, the new window will be centered with respect to the screen. HTML names can be applied to both the new window and the original opener window (the one containing this script). The new window can also be given a status bar, scrollbars, and other GUI elements.

openCenteredWindow()

Synopsis

openCenteredWindow(url, name, width, height, status, scrollbars, moreProperties, openerName)

Arguments

url

The url of the document that should appear in the new window as soon as it is created.

name

The HTML name to be given to the window. This name may contain only letters, numbers and underscores. This name can be used to target links into the new window using the target attribute of the <a href> tag.

width

The interior width of the new window (the full width, including the window edge, will be bigger).

height

The interior height of the new window (the full height, including the window edge, titlebar and status bar, will be bigger).

status

An optional argument that specifies whether the new window should have a status bar at the bottom. Any non-empty (such as true) will indicate that a status bar is required.

scrollbars

An optional argument that specifies whether the new window should have scrollbars. Any non-empty value (such as true) will indicate that scrollbars are required.

moreProperties*

An optional argument that specifies properties (other than a status bar and scrollbars) that may be added to the window. This should be a quoted, comma-separated list of property names. Valid property names are limited to those acceptable in the 3rd argument to the window.open() method.

openerName

An optional HTML name to be given to the opener window (the window containing the script). This name may contain only letters, numbers and underscores. This allows links in the new window to target the opener window using the target attribute of the <a href> tag.

Returns

A reference to the new window. This reference can be used to manipulate the new window after it has been created.

Description

openCenteredWindow() creates a new window of given dimensions in the center of the screen and returns a reference to the new window. HTML names can be applied to both the new window and the original opener window (the one containing this script). The new window can also be given a status bar, scrollbars, and other GUI elements.

openFullChromeWindow()

Synopsis

openFullChromeWindow(url, name, openerName)

Arguments

url

The url of the document that should appear in the new window as soon as it is created.

name

The HTML name to be given to the window. This name may contain only letters, numbers and underscores. This name can be used to target links into the new window using the target attribute of the <a href> tag.

openerName

An optional HTML name to be given to the opener window (the window containing the script). This name may contain only letters, numbers and underscores. This allows links in the new window to target the opener window using the target attribute of the <a href> tag.

Returns

A reference to the new window. This reference can be used to manipulate the new window after it has been created.

Description

openFullChromeWindow() creates a new window with full menubars, toolbars, and other GUI elements and returns a reference to the new window. HTML names can be applied to both the new window and the original opener window (the one containing this script). The operating system determines the dimensions and position of the new window.

openMaxedWindow()

Synopsis

openMaxedWindow(url, name, scrollbars, openerName)

Arguments

url

The url of the document that should appear in the new window as soon as it is created.

name

The HTML name to be given to the window. This name may contain only letters, numbers and underscores. This name can be used to target links into the new window using the target attribute of the <a href> tag.

scrollbars

An optional argument that specifies whether the new window should have scrollbars. Any non-empty value (such as true) will indicate that scrollbars are required.

openerName

An optional HTML name to be given to the opener window (the window containing the script). This name may contain only letters, numbers and underscores. This allows links in the new window to target the opener window using the target attribute of the <a href> tag.

Returns

A reference to the new window. This reference can be used to manipulate the new window after it has been created.

Description

openMaxedWindow() creates a new window that fills the screen and returns a reference to the new window. HTML names can be applied to both the new window and the original opener window (the one containing this script).

openPositionedWindow()

Synopsis

openPositionedWindow(url, name, width, height, x, y, status, scrollbars, moreProperties, openerName)

Arguments

url

The url of the document that should appear in the new window as soon as it is created.

name

The HTML name to be given to the window. This name may contain only letters, numbers and underscores. This name can be used to target links into the new window using the target attribute of the <a href> tag.

width

The interior width of the new window (the full width, including the window edge, will be bigger).

height

The interior height of the new window (the full height, including the window edge, titlebar and status bar, will be bigger).

x

The displacement of the top-left corner of the new window from the screen's left edge measured in pixels.

y

The displacement of the top-left corner of the new window from the screen's top edge measured in pixels.

status

An optional argument that specifies whether the new window should have a status bar at the bottom. Any non-empty value (such as true) will indicate that a status bar is required.

scrollbars

An optional argument that specifies whether the new window should have scrollbars. Any non-empty value (such as true) will indicate that scrollbars are required.

moreProperties*

An optional argument that specifies properties (other than a status bar and scrollbars) that may be added to the window. This should be a quoted, comma-separated list of property names. Valid property names are limited to those acceptable in the 3rd argument to the window.open() method.

openerName

An optional HTML name to be given to the opener window (the window containing the script). This name may contain only letters, numbers and underscores. This allows links in the new window to target the opener window using the target attribute of the <a href> tag.

Returns

A reference to the new window. This reference can be used to manipulate the new window after it has been created.

Description

openPositionedWindow() creates a new window of given dimensions and at a given position on the screen and returns a reference to the new window. HTML names can be applied to both the new window and the original opener window (the one containing this script). The new window can also be given a status bar, scrollbars, and other GUI elements.

openSizedFullChromeWindow()

Synopsis

openSizedFullChromeWindow(url, name, width, height, openerName)

Arguments

url

The url of the document that should appear in the new window as soon as it is created.

name

The HTML name to be given to the window. This name may contain only letters, numbers and underscores. This name can be used to target links into the new window using the target attribute of the <a href> tag.

width

The interior width of the new window (the full width, including the window edge, will be bigger).

height

The interior height of the new window (the full height, including the window edge, titlebar and status bar, will be bigger).

openerName

An optional HTML name to be given to the opener window (the window containing the script). This name may contain only letters, numbers and underscores. This allows links in the new window to target the opener window using the target attribute of the <a href> tag.

Returns

A reference to the new window. This reference can be used to manipulate the new window after it has been created.

Description

Like openFullChromeWindow() but window dimensions can be specified. The operating system determines the position of the new window.

Modal Dialog Functions

closeDialog()

Synopsis

closeDialog(window)

Arguments

window

A reference to the dialog window.

Returns

Nothing.

Description

closeDialog() is meant as a clean-up function to close a dialog window before leaving the parent window. It is meant to be called from the onunload event handler of the <body> tag of a document that can create dialogs. It will check to make sure a dialog was opened and not closed before attempting to close it.

closeParentDialog()

Synopsis

closeParentDialog()

Returns

Nothing.

Description

closeParentDialog() should be used to keep only one dialog window open at any one time when dialogs may spawn from other dialogs. It is meant to be called from the onload event handler of the <body> tag of a document that can appear in a dialog. It simply switches the opener property of the window to the top-most parent (the main window) and closes the previous dialog. You have to be responsible for setting the reference from the main window to the popup correctly so that any closeDialog() calls in the main window work correctly.

*moreProperties

The usage of moreProperties is intended for "power users" who would like more control over the appearance of windows. Specifying more properties could cause the dimensions of your window to be off from that specified in width and height properties. This may be corrected in future releases of this script.

More about this script

Related to this script

Licensing

This script is released under a Creative Commons License.