JavaScript Window Function Guide Reference The window has been opened

zhaozj2021-02-08  221

JavaScript Window Function Guide Reference The window has been opened

(Author: hear the wind compiler 2001 at 11:35 on January 19)

If you want to associate a specified window, you can use the "Target property of the tag. A browser window does not have a name unless you assign you. When you use the target property to open a new window via a link, you assign a clear name: Intel The front link opens a new window and called Review. The following link produces the same effect by javascript: DOC JavaScript The attribute Opener property setting or retrieve the reference to the window that creates the current window. When the OPEN () method opens a source document on the target window, the Opener property (Window object belonging to the target window) defines the window where the source document is located. This property has been existed in the window opened, so it is still accessible even if the URL in the new window changes. The Opener property is a reference to the parent window Window object, so you can make full use of this property, through the script, execute any action on the open window in a new window. For example, use the following script to modify the background color of the open window in the target document: window.opener.document.bgcolor = "beige"; huh, if you are too sensitive, you may notice the error of this statement above. We must check if the window still exists before you can decide to modify its related properties. Here is the correct code: if (Window.opener &&! Window.opener.closed) window.opener.document.bgcolor = "beige"; Opener property is very useful because it creates two-way window and the open window contact.

Let us give a practical example and see if it works, the following is an HTML code that appears on the home page:

Enter your favorite tech stock: Note, the name of the form is stockform, text field The name is the stockbox, the "List" button activates the showlist () function. At the same time, set the ONUNLOAD event handler in the tag of the document, which will execute the REMLINK () function. Below is the code of these 2 functions: