Iframe is a very commonly used html element. How should I write the method of using child pages in the parent page? Let’s give a brief introduction below.
1. Parent page code
<html> <head> <meta charset=" gb2312"> <title>Parent page</title> <script type="text/javascript"> function parentFunction() { alert('function in parent'); } function callChild() { (); /* child is the name attribute value of the iframe, Cannot be id, because id cannot get iframe object under FireFox */ } </script> </head> <body> <iframe name="child" src="./" ></iframe> </body> </html>
2. Code in iframe
<html> <head> <meta charset="gb2312"> <title>iframeCode</title> <script type="text/javascript"> function childFunction() { alert('function in child'); } function callParent() { (); } </script> </head> <body> </body> </html>
The above two codes can call each other's functions on the parent page and the child page. It is relatively simple and will not be introduced more.
I hope that the description in this article will be helpful to everyone to learn JavaScript programming.