The example in this article describes how JavaScript child windows invoke the parent window variables and functions. Share to everyone for your reference. Specifically as follows:
Example 1: A child window is a newly opened window
Parent window:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en"
"http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">
child window:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en"
"http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">
You can access the specified resource as long as you add opener to the variables and functions.
However, when the parent window is closed, it will report a mistake: "The object being invoked has been disconnected from its client." "
Example 2: A child page is an IFRAME of the parent page
Parent page:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en"
"http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">
Sub page:
<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en"
"http://www.w3.org/TR/xhtml1/DTD/ Xhtml1-transitional.dtd ">
Small discovery: When the parent page is refreshed, the IFRAME is refreshed with it, and the parent page does not refresh when the IFRAME is refreshed.
I hope this article will help you with your JavaScript programming.