设置open方法中的参数-ASP技术-3P代码网
繁体中文
设为首页
加入收藏
当前位置:ASP技术首页 >> ASP基础 >> 设置open方法中的参数

设置open方法中的参数

2006-06-15 08:00:00  作者:  来源:互联网  浏览次数:0  文字大小:【】【】【
简介:open method (window object) Opens a new web browser window. 语法 [windowVar = ][window].open("URL", "windowName", ["windowFeatures"]) windowVar is the name of a ne...
关键字:参数 方法 open

open method (window object)

Opens a new web browser window.


语法

[windowVar = ][window].open("URL", "windowName", ["windowFeatures"])


windowVar is the name of a new window. Use this variable when referring to a window's properties, methods, and containership.

URL specifies the URL to open in the new window. See the location object for a description of the URL components.

windowName is the window name to use in the TARGET attribute of a

or 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.



onClick="window.open

('sesame.htm', 'newWin', 'scrollbars=yes,status=yes,width=300,height=300')">



Notice the use of single quotes (') inside the onClick event handler.

相关文章