The method window.close() will attempt to close the window in which the script is executing. This is only possible without a user confirmation dialog if the script has the UniversalBrowserWrite privilege. The statement self.close() is effectively window.close() and will also attempt to close the window in which the script is executing.
A JavaScript running inside a window may close that window.
JavaScripts running outside a window may or may not be able to close that window. This may be implementation dependent and may also depend on the value of the opener property of the target window and the current security policy in force. Attempts to close windows that your JavaScript did not open will elicit a user dialog to get permission to close the window. This is so that people cannot write invasive scripts that wreak havoc on your browser session when they are loaded.
The default behavior is to allow JavaScript to close windows which were opened by scripts that were originally served from the same server and which were not opened by the user. This may be overridden if additional privileges are granted to scripts.
From version 1.1 of JavaScript, (generally speaking) you can only close windows that were opened by JavaScript from within a script. Although, certain browser privileges will allow you to close other windows and this behavior may be browser dependent.
Do not confuse this method with the document.close() method. They are not the same.
Do not call this for Window objects that represent frames, you cannot close a single frame within a window.
Prev | Home | Next |
Window.clipboardData | Up | Window.closed |
JavaScript Programmer's Reference, Cliff Wootton Wrox Press (www.wrox.com) Join the Wrox JavaScript forum at p2p.wrox.com Please report problems to support@wrox.com © 2001 Wrox Press. All Rights Reserved. Terms and conditions. |