window.open()用法总结

一、window.open()支持环境:
JavaScript1.0+/JScript1.0+/Nav2+/IE3+/Opera3+

二、基本语法:
window.open(pageURL,name,parameters)
其中:
pageURL 为子窗口路径
name 为子窗口句柄
parameters 为窗口参数(各参数用逗号分隔)

三、示例:
<SCRIPT>
<!–
window.open (‘page.html’,’newwindow’,’height=100,width=400,top=0,left=0,toolbar=no,menubar=no,scrollbars=no, resizable=no,location=no, status=no’);
–>
</SCRIPT>

脚本运行后,page.html将在新窗体newwindow中打开,宽为100,高为400,距屏顶0象素,屏左0象素,无工具条,无菜单条,无滚动条,不可调整大小,无地址栏,无状态栏。

上例中涉及的为常用的几个参数,除此以外还有很多其他参数,请见四。

四、各项参数
其中yes/no也可使用1/0;pixel value为具体的数值,单位象素。

参数 | 取值范围 | 说明

alwaysLowered | yes/no | 指定窗口隐藏在所有窗口之后
alwaysRaised | yes/no | 指定窗口悬浮在所有窗口之上
depended | yes/no | 是否和父窗口同时关闭
directories | yes/no | Nav2和3的目录栏是否可见
height | pixel value | 窗口高度
hotkeys | yes/no | 在没菜单栏的窗口中设安全退出热键
innerHeight | pixel value | 窗口中文档的像素高度
innerWidth | pixel value | 窗口中文档的像素宽度
location | yes/no | 位置栏是否可见
menubar | yes/no | 菜单栏是否可见
outerHeight | pixel value | 设定窗口(包括装饰边框)的像素高度
outerWidth | pixel value | 设定窗口(包括装饰边框)的像素宽度
resizable | yes/no | 窗口大小是否可调整
screenX | pixel value | 窗口距屏幕左边界的像素长度
screenY | pixel value | 窗口距屏幕上边界的像素长度
scrollbars | yes/no | 窗口是否可有滚动栏
titlebar | yes/no | 窗口题目栏是否可见
toolbar | yes/no | 窗口工具栏是否可见
Width | pixel value | 窗口的像素宽度
z-look | yes/no | 窗口被激活后是否浮在其它窗口之上


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~分割线~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

还有一篇英文版的可以参考:

syntax:window.open(URL,name,specs,replace)

Parameter Description

URL
Optional. Specifies the URL of the page to open. If no URL is specified, a new window with about:blank is opened

name
Optional. Specifies the target attribute or the name of the window. The following values are supported:

_blank – URL is loaded into a new window. This is default
_parent – URL is loaded into the parent frame
_self – URL replaces the current page
_top – URL replaces any framesets that may be loaded
name – The name of the window

specs
Optional. A comma-separated list of items. The following values are supported:

channelmode=yes|no|1|0
Whether or not to display the window in theater mode. Default is no

directories=yes|no|1|0
Whether or not to add directory buttons. Default is yes

fullscreen=yes|no|1|0
Whether or not to display the browser in full-screen mode. Default is no. A window in full-screen mode must also be in theater mode

height=pixels
The height of the window. Min. value is 100

left=pixels
The left position of the window

location=yes|no|1|0
Whether or not to display the address field. Default is yes

menubar=yes|no|1|0
Whether or not to display the menu bar. Default is yes

resizable=yes|no|1|0
Whether or not the window is resizable. Default is yes

scrollbars=yes|no|1|0
Whether or not to display scroll bars. Default is yes

status=yes|no|1|0
Whether or not to add a status bar. Default is yes

titlebar=yes|no|1|0
Whether or not to display the title bar. Ignored unless the calling application is an HTML Application or a trusted dialog box. Default is yes

toolbar=yes|no|1|0
Whether or not to display the browser toolbar. Default is yes

top=pixels
The top position of the window

width=pixels
The width of the window. Min. value is 100

replace
Optional.Specifies whether the URL creates a new entry or replaces the current entry in the history list. The following values are supported:

true – URL replaces the current document in the history list
false – URL creates a new entry in the history list

from:http://www.w3schools.com/htmldom/met_win_open.asp

此条目发表在sitebuild分类目录,贴了标签。将固定链接加入收藏夹。

发表评论

您的电子邮箱地址不会被公开。

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据