open method
Opens a new window and loads the document specified by a given URL.
打开一个新窗口并加载由给定的 URL 指定的文档。
Navigates the app window to the specified location.
导航应用程序窗口到指定的位置。
Syntax
var retval = window.open(url, name, features, replace);
var retval = 的 window.open (url、 名称、 特点、 替换);
Parameters
url [in, optional]
[中,可选] 的 url
Type: String
String that specifies the URL of the document to display. If no URL is specified, a new window with about:blank is displayed.
String指定要显示文档的URL。如果没有指定URL,则关于新窗口: 显示空白。
name [in, optional]
Type: String
String that specifies the name of the window. This name is used as the value for the TARGET attribute on a form or an anchor element.
String指定窗口的名称。这个名字被用作目标属性的值在一个窗体或锚元素。
_blank
The url is loaded into a new, unnamed window.
该 url 加载到一个新的未命名窗口。
_parent
The url is loaded into the current frame's parent. If the frame has no parent, this value acts as the value
Url 被加载到当前帧父。如果帧没有父,此值充当值 _self。
_self
The current document is replaced with the specified url.
当前文档被替换为指定的 url。
_top
The loaded url replaces any framesets that might be loaded. If there are no framesets defined, this value acts as the value _self.
加载的 url 替换可能会加载的任何框架集。如果没有定义的框架集,此值充当值 _self。
features [in, optional]
Type: String
String that contains a list of items separated by commas. Each item consists of an option and a value, separated by an equals sign (for example, "fullscreen=yes, toolbar=yes"). The following values are supported.
String包含由逗号分隔的项列表。每个项目包括的选项和值,用等号分隔(例如,"fullscreen=yes, toolbar=yes")。支持下列值。
channelmode = { yes | no | 1 | 0 }
Specifies whether to display the window in theater mode. The default is no.
指定是否在剧场模式中显示窗口。默认值是没有。
Internet Explorer 7. channelmode = { yes | 1 } overrides height, width, top, and left values. When active, the Navigation Bar is hidden and the Title Bar is visible. The Channel Band is no longer supported in Internet Explorer 7.
Internet explorer 7。channelmode = { yes | 1 } 将覆盖高度、 宽度、 上边框和左的值。激活时,隐藏导航栏和标题栏是可见。在 Internet Explorer 7 不再支持通信信道的带宽。
In Internet Explorer 6, channelmode = { yes | 1 } displays the Channel Band in theater mode.
在Internet Explorer 6中,channelmode = { yes | 1 } 在剧场模式中显示通信信道的带宽。
fullscreen = { yes | no | 1 | 0 }
Specifies whether to display the browser in full-screen mode. The default is no. Use full-screen mode carefully. Because this mode hides the browser's title bar and menus, always provide a button or other visual clue to help the user close the window. ALT+F4 closes the new window.
指定是否显示浏览器全屏模式。默认是否定的。谨慎地使用全屏模式。因为这种模式隐藏浏览器的标题栏和菜单,总是提供一个按钮或其他视觉线索来帮助用户关闭窗口。ALT + F4关闭新窗口。
Internet Explorer 7. A window in full-screen mode doesn't need to be in theater mode.
Internet explorer 7。在全屏幕模式下的窗口并不需要在影院模式下。
In Internet Explorer 6, a window in full-screen mode must also be in theater mode (channelmode).
在Internet Explorer 6中,在全屏模式下的窗口也必须在剧场模式 (channelmode)。
height = number
Sets the height of the window in pixels. The minimum value is 150, and specifies the minimum height of the browser content area.
以像素为单位设置窗口的高度。最小值为 150,并指定浏览器内容区域的最低高度。
In Internet Explorer 6, the minimum height value is 100.
在Internet Explorer 6中,最小高度值为100。
left = number
Specifies the left position, in pixels. This value is relative to the upper-left corner of the screen. The value must be greater than or equal to 0.
指定的左边的位置,以像素为单位。此值是相对于屏幕的左上角。值必须是大于或等于 0。
location = { yes | no | 1 | 0 }
Specifies whether to display the Navigation Bar. The default is yes.
指定是否显示导航栏。默认值为是。
In Internet Explorer 6, location specifies whether to display the Address Bar.
在Internet Explorer 6中,指定是否显示地址栏位置。
The Back, Forward, and Stop commands are now located in the Navigation Bar.
后退,前进,停止命令现在位于导航栏。
In Internet Explorer 6, the navigation commands were located in the toolbar.
在Internet Explorer 6中,导航命令位于工具栏。
menubar = { yes | no | 1 | 0 }
Specifies whether to display the Menu Bar. The default is yes.
指定是否显示菜单栏。默认值为yes。
Internet Explorer 7. By default, the menu bar is hidden unless revealed by the ALT key. menubar = { no | 0 } prohibits the Menu Bar from appearing even when the ALT key is pressed.
Internet explorer 7。默认情况下,菜单栏被隐藏,除非显示的 ALT 键。菜单栏 = {no | 0} 禁止菜单栏甚至出现时按下 ALT 键。
The combination of menubar = { no | 0 } and toolbar = { no | 0 } hides the toolbar and disables any additional third-party user interfaces.
菜单栏的组合 = {no | 0 } 和工具栏 = {no | 0 } 隐藏工具栏并禁用任何其他第三方用户接口。
resizable = { yes | no | 1 | 0 }
Specifies whether to display resize handles at the corners of the window. The default is yes.
指定是否显示在窗口角的大小调整控柄。默认值为yes。
Internet Explorer 7. resizable = { no | 0 } disables tabs in a new window.
Internet explorer 7。 resizable = { no | 0 } 禁用在新窗口中的选项卡。
scrollbars = { yes | no | 1 | 0 }
Specifies whether to display horizontal and vertical scroll bars. The default is yes.
指定是否显示水平和垂直滚动条。默认值为yes。
status = { yes | no | 1 | 0 }
Specifies whether to add a Status Bar at the bottom of the window. The default is yes.
指定是否要在窗口的底部添加一个状态栏。默认值为yes。
toolbar = { yes | no | 1 | 0 }
Specifies whether to display the browser Command Bar, making buttons such as Favorites Center, Add to Favorites, and Tools available. The default is yes.
指定是否要显示浏览器命令栏,制作等收藏中心,添加到收藏夹按钮,以及工具可用。默认值为yes。
The combination of menubar = { no | 0 } and toolbar = { no | 0 } turns off the toolbar and any additional third-party user interfaces.
菜单栏的组合 = { no | 0 } 和工具栏 = { no | 0 } 关闭工具栏和任何其他第三方用户接口。
In Internet Explorer 6, the toolbar sFeatures specifies whether to display the browser toolbar, making buttons such as Back, Forward, and Stop available.
在Internet Explorer 6中,工具栏 sFeatures 指定是否显示浏览器工具栏上,制作按钮如后退、 前进、 并停止可用。
top = number
Specifies the top position, in pixels. This value is relative to the upper-left corner of the screen. The value must be greater than or equal to 0.
指定顶部的位置,以像素为单位。这个值是相对于屏幕的左上角。该值必须大于或等于0。
width = number
Sets the width of the window in pixels. The minimum value is 250, and specifies the minimum width of the browsers content area.
设置窗口的宽度,以像素为单位。最小值为 250,并指定浏览器内容区域的最小宽度。
In Internet Explorer 6, the minimum height value is 100.
在Internet Explorer 6中,最小高度值为100。
Return value
Type: IHTMLWindow2
Returns a reference to the new window object. Use this reference to access properties and methods on the new window.
返回到新的窗口对象的引用。在新窗口中使用此引用来访问属性和方法。
When the features parameter is specified, the features that are not defined in the parameter are disabled. Therefore, when using the features parameter, it is necessary to enable all the features that are to be included in the new window. If the features parameter is not specified, the window features maintain their default values. In addition to enabling a feature by setting it to a specific value, simply listing the feature name also enables that feature for the new window. Most of the features specified in the window.open method are ignored if user has selected, "Always open pop-ups in a new tab" setting in the Internet options control panel.
指定的特性参数,参数中定义的特性,并不都是禁用的。因此,当使用的特征参数,它就要启用要在新窗口中包含的所有功能。如果不指定特征参数,则窗口功能维持它们的默认值。除了启用功能通过将它设置为一个特定的值,只列出功能名称也使该功能的新窗口。如果用户已选定,"始终在新选项卡中打开弹出窗口",则将忽略在 window.open 方法中指定的特性中的大部分在 Internet 控制面板中的选项设置。
When a function fired by an event on any object calls the open method, the window.open method is implied.
当一个函数发射的事件上任何对象调用 open 方法时,window.open 方法被隐含。
When an event on any object calls the open method, the document.open method is implied.
Windows Internet Explorer 8. New windows and pop-ups always inherit the zoom level of the parent window.
Windows Internet Explorer 8。新的窗口和弹出式窗口始终继承父窗口的缩放级别。
Internet Explorer 7. The Back, Forward, and Stop commands are now located in the Navigation bar of the user interface. Prior to Internet Explorer 7 navigation commands were located in the toolbar.
Internet Explorer 7。后退,前进,停止命令现在位于用户界面的导航栏中。在 Internet Explorer 7 之前导航命令位于工具栏。
Internet Explorer 7在Windows Vista 上。从应用程序不是在 Internet Explorer 进程打开一个新窗口可能会导致 NULL 返回值。这是因为互联网资源管理器默认在保护模式下运行。保护的模式阻止应用程序从特权访问到 Internet Explorer 时访问跨越进程边界。因为在新的进程中,此方法打开窗户,保护的模式到新窗口限制访问。有关详细信息,请参阅了解和保护模式互联网资源管理器中工作。
Internet Explorer 6 for Windows XP Service Pack 2 (SP2) places several restrictions on windows created with this method. For several of the parameter values listed in the Parameters table, these restrictions are indicated by the minimum value. For more information, see About Window Restrictions.
Internet Explorer 6为Windows XP Service Pack 2(SP2)地方一些限制在Windows上使用这种方法创建。几个参数表中列出的参数值,这些限制的最小值表示。有关详细信息,请参阅关于窗口限制。
This method must use a user-initiated action, such as clicking on a link or tabbing to a link and pressing enter, to open a pop-up window. The Pop-up Blocker feature in Internet Explorer 6 blocks windows that are opened without being initiated by the user. The Pop-up Blocker also prevents windows from appearing if you call this method from an onunload event.
此方法必须使用用户启动的操作,如点击一个链接或 tab 键定位到一个链接并按输入,以打开一个弹出窗口。在Internet Explorer 6 中的弹出窗口阻止程序功能阻止不由用户发起的情况下打开的窗口。弹出窗口阻止程序也可以防止 windows 出现如果从 onunload 事件调用此方法。
Examples
This example uses the open method to create a new window that contains Sample.htm. The new window is 200 pixels by 400 pixels and has a status bar, but it does not have a toolbar, menu bar, or address field.
此示例使用 open 方法来创建一个新的窗口,包含 Sample.htm。新窗口是 200 x 400 像素和有一个状态栏,但它并没有工具栏、 菜单栏或地址字段。