Opener is the one who opened me. For example, Page A uses Window.open to pop up the B. Page window window. Then the window where the A page is located is the opener of the page B. Page can access the A page on the BPENER object.
Parent indicates that the parent window, such as a page A uses iframe or frame to call the B page, then the window where the page A is located is the Parent on page B. In JS, Window.opner is only a reference to the mother window in the pop -up window. For example: in A.html, a new window is made by clicking the button, etc. Window.open B.HTML. Then in B.HTML, you can reference A.HTML through Window.Opener (omitted as Opener), including A.HTML document and other objects to operate the content of A.HTML.
If this reference fails, it will return Null. Therefore, before calling the OPENER object, you must first determine whether the object is null, otherwise the JS error with "the object is empty or does not exist" will appear.
Example:
aa.html
Copy code code as follows:
<! Doctype HTML PUBLIC "-// W3C // DTD XHTML 1.0 Transitional // EN" http://www.w3.org/xhtml1/dtddml1-transitationAl.dtd ">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" /> />
<Title> Non -Title Document </Title>
</head>
<body>
<span ID = "name"> </span>
<input type = "Button" "Value =" Pop -up "onClick =" Window.open ('BB.HTML') " /> />
</body>
</html
bb.html
Copy code code as follows:
<! Doctype HTML PUBLIC "-// W3C // DTD XHTML 1.0 Transitional // EN" http://www.w3.org/xhtml1/dtddml1-transitationAl.dtd ">
<html xmlns = "http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv = "content-type" content = "text /html; charset = utf-8" /> />
<Title> Non -Title Document </Title>
</head>
<body>
<input type = "text" id = "inputValue"/>
<input type = "Button" value = "Add" Onclick = "Window.opent.document.GetelementByid ('name'). InnerHtml = InputValue.value"/>
</body>
</html>
Window.opner returns the reference to the window that creates the current window. For example, clicking a link on AA.HTM to open the bb.htm, and then we intend to enter a value on the bb.htm and give it to AA.HTM on AA.HTM In a textbox with "name", you can
Written as:
Window.opner.document.GetelementByid ("name"). Value = "Input data";
Window.opner.document.GetelementByid ("name"). Innerhtml = "Enter data";