Availability: |
| ||||||
Property/method value type: | Window object | ||||||
JavaScript syntax: | - | aNewWindow = myWindow.open() | |||||
- | aNewWindow = myWindow.open(aURL) | ||||||
- | aNewWindow = myWindow.open(aURL, aName) | ||||||
- | aNewWindow = myWindow.open(aURL, aName, aFeatureList) | ||||||
- | aNewWindow = myWindow.open(aURL, aName, aFeatureList, aFlag) | ||||||
- | aNewWindow = open() | ||||||
- | aNewWindow = open(aURL) | ||||||
- | aNewWindow = open(aURL, aName) | ||||||
- | aNewWindow = open(aURL, aName, aFeatureList) | ||||||
- | aNewWindow = open(aURL, aName, aFeatureList, aFlag) | ||||||
Argument list: | aFeatureList | A list of attributes for the new window | |||||
aFlag | A flag to indicate how the history list is to be modified | ||||||
aName | The name of a new or existing target window | ||||||
aURL | A URL to load into the window |
All arguments are optional. However, since they are also positional, you must use commas and empty strings as necessary to null out the entries you don't require if you need the later ones.
The URL value, if specified, will fetch and load the document into the window as the window.open() method is executed. You may omit or null the URL with an empty string. This will open a new window but not load anything into it.
The name identifies the target window. If that window name is not already used, then a new window will be created, otherwise the URL will replace the existing content. When you direct a null URL to an already open window being referenced by name just returns a reference to that window object. This may be useful if you know the name of a window but do not have a handle on its object representation. If you do not specify a name, then a new unnamed window will be created.
The feature list describes the attributes of the window. This may in some implementations allow you to change a window's appearance but this may not always be possible. The feature list must be comma separated and must not contain any spaces.
The flag value indicates what you want done with the history table for this window. Passing the Boolean true value indicates that the new URL should replace the existing history entry. A Boolean false value indicates that the new URL should be added to the tail of the history list. This facility is available from JavaScript version 1.1 onwards.
The value returned by this open() method is a reference to the window object that represents the window that has just been opened. You can store this in a variable so you can send messages to the window when necessary.
See the Window features list topic for a list of the window feature names and the values that they expect, and a discussion on the limitations and some subtle catch-outs and differences between the browsers.
This method returns a reference to the window object for the window that was created or updated. You should note this in some persistent variable if you plan to communicate with the window some time later during the session.
Do not confuse the window.open() method with the document.open() method. It is probably a safer technique to explicitly refer to the window.open() method rather than rely on the implication of the open() method being sent to a window object. It might be possible to modify the scope chain to make this default to document.open() instead.
A window.open() will create a new viewport window. A document.open() will clear the current window contents and start writing new HTML into it.
If you include spaces in the feature list attribute, the script may cause some versions of Netscape Navigator to crash horribly and on others it will just ignore any features following the space character.
Netscape Navigator returns an EventCapturer object instead of a Window object.
The window.open() method will behave differently in JellyScript on a WebTV set-top box when compared with the behavior in a normal computer based web browser. It creates a pseudo-window in an <IFRAME> and appends it to the end of the current display. The user can then scroll down to this window.
Prev | Home | Next |
Window.onunload | Up | Window.opener |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |