When you create a new window, allocate the return value of the Open () method to a variable is very important. For example, the following statement is to create a new window and close it immediately:
Win = WINDOW.OPEN ("http://www.docjs.com/", "js");
Win.Close ();
Each browser window is clearly written with a Window object, so when you want to reference the current window, you should use the Window object. The following statement sets the URL of the current window:
Window.location.href = "http://www.docjs.com/";
When you place such a statement in the script, you don't need to specify a Window object, because the existence of the current window is default:
Location.href = "http://www.docjs.com/";
Note that Self is equivalent to Window, so self.close () is actually equal to Window.Close ().
Window.location.href = "http://www.docjs.com/";
close the window
Window.close () Turn off the specified browser window. If the close () function is called without a window reference, JavaScript turns off the current window. In an event handler, you must specify Window.Close () without using Close (). Due to the scope of JavaScript total static object, a close () call without object name is equivalent to document.close ().
If you perform a close () method to close a window that is not opened by the script, a confirmation dialog will have a confirmation dialog to select whether to close the window. If there is only a record in the historical list, the dialog box will not appear in the Navigator. However, if you use Close () to exit the last running browser instance, the confirmation dialog will appear. See the dialog box that appears in the 2-type browser looks like:
Click on the link below to open a new window, where the content is TryClose.html:
Launch Window (with JavaScript)
Launch Window (with HTML)
The first link uses JavaScript's Window.Open () method to open a window, and the second link simply uses the target attribute to achieve the same purpose:
launch window (with javascript)
Page TryClose.html Displays a button, it is responsible for performing a window.close () method: