JavaScript: The Definitive Guide, Sixth Editio javaScript权威指南(第6版) pdf 文字版-文字版, javascript电子书, 和javascript 有关的电子书:

14.8.1 Opening and Closing Windows

14.8.1 Opening and Closing Windows


You can open a new web browser window (or tab; this is usually a browser configuration option) with the open() method of the Window object. Window.open() loads a specified URL into a new or existing window and returns the Window object that represents that window. It takes four optional arguments:

The first argument to open()is the URL of the document to display in the new window. If this argument is omitted (or is the empty string), the special blank-page URL about:blank is used.

The second argument to open() is a string that specifies a window name. If a window by that name already exists (and if the script is allowed to navigate that window), that existing window is used. Otherwise a new window is created and is assigned the specified name. If this argument is omitted, the special name “_blank” is used: it opens a new, unnamed window.

Note that scripts cannot simply guess window names and take over the windows in use by other web applications: they can only name existing windows that they are “allowed to navigate” (the term is from the HTML5 specification). Loosely, a script can specify an existing window by name only if that window contains a document from the same origin or if the script opened that window (or recursively opened a window that opened that window). Also, if one window is a frame nested within the other, a script in either one can navigate the other. In this case, the reserved names “_top” (the top-level ancestor window) and “_parent” (the immediate parent window) can be useful.

Window Names

The name of a window is important because it allows the open() method to refer to existing windows, and also because it can be used as the value of the HTML target attribute on andelements to indicate that the linked document (or the result of submitting the form) should be displayed in the named window. The targetattribute on these elements can also be set to “_blank”, “_parent”, or “_top” to direct the linked document into a new blank window, the parent window or frame, or the top-level window.

The name property of a Window object holds its name, if it has one. This property is writable, and scripts can set it as desired. If a name (other than “_blank”) is passed to Window.open(), the window created by that call will have the specified name as the initial value of its name property. If an

欢迎转载,转载请注明来自一手册:http://yishouce.com/book/1/27917.html
友情链接It题库(ittiku.com)| 版权归yishouce.com所有| 友链等可联系 admin#yishouce.com|粤ICP备16001685号-1