tag. windowName can contain only alphanumeric or underscore (_) characters.
windowFeatures is a comma-separated list of any of the following options and values:
toolbar[=yes|no]|[=1|0]
location[=yes|no]|[=1|0]
directories[=yes|no]|[=1|0]
status[=yes|no]|[=1|0]
menubar[=yes|no]|[=1|0]
scrollbars[=yes|no]|[=1|0]
resizable[=yes|no]|[=1|0]
width=pixels
height=pixels
You may use any subset of these options. Separate options with a comma. Do not put spaces between the options.
pixels is a positive integer specifying the dimension in pixels.
Method of
window
Description
The open method opens a new web browser window on the client, similar to choosing New Web Browser from the File menu of the Navigator. The URL argument specifies the URL contained by the new window. If URL is an empty string, a new, empty window is created.
In event handlers, you must specify window.open() instead of simply using open(). Due to the scoping of static objects in JavaScript, a call to open() without specifying an object name is equivalent to document.open().
windowFeatures is an optional, comma-separated list of options for the new window. The boolean windowFeatures options are set to true if they are specified without values, or as yes or 1. For example, open("", "messageWindow", "toolbar") and open("", "messageWindow", "toolbar=1") both set the toolbar option to true. If windowName does not specify an existing window and you do not specify windowFeatures, all boolean windowFeatures are true by default. If you specify any item in windowFeatures, all other Boolean windowFeatures are false unless you explicitly specify them.
Following is a description of the windowFeatures:
toolbar creates the standard Navigator toolbar, with buttons such as "Back" and "Forward", if true
location creates a Location entry field, if true
directories creates the standard Navigator directory buttons, such as "What's New" and "What's Cool", if true
status creates the status bar at the bottom of the window, if true
menubar creates the menu at the top of the window, if true
scrollbars creates horizontal and vertical scrollbars when the document grows larger than the window dimensions, if true
resizable allows a user to resize the window, if true
width specifies the width of the window in pixels
height specifies the height of the window in pixels
例子
In the following example, the windowOpener function opens a window and uses write methods to display a message:
function windowOpener() {
msgWindow=window.open("","displayWindow","menubar=yes")
msgWindow.document.write
("
Message window")
msgWindow.document.write
("
Hello, world!")
}
The following is an onClick event handler that opens a new client window displaying the content specified in the file sesame.htm. The window opens with the specified option settings; all other options are false because they are not specified.
Notice the use of single quotes (') inside the onClick event handler.