The example of this paper describes the method of JS to implement the cross page call function of the IFRAME. Share to everyone for your reference. The implementation methods are as follows:
The problem with the project is that the page introduces an IFRAME and requires the parent page function to call the child page function or the child page. For example, there are now two pages parent.html and child.html. The parent.html contains an IFRAME and the IFRAME points to child.html. Now you need to call a JS method of child.html/parent.html in parent.html/child.html.
The specific code implementation is as follows:
Parent.html Parent page:
Copy Code code as follows:
<script type= "Text/javascript" >
function Parent_click () {
Alert ("From parent page");
}
</script>
<body>
<input type= "button" value= "Call this page function" onclick= "Parent_click ();"/>
<input type= "button" value= "Call child page function" onclick= ' window.frames["Childpage"].child_click (); '/>
<iframe id= "Childpage" name= "Childpage" src= "inner.html" width= "100%" frameborder= "0" ></iframe>
</body>
child.html Child page:
Copy Code code as follows:
<script type= "Text/javascript" >
function Child_click () {
Alert ("Called Child page Function");
}
</script>
<body>
<input type= "button" value= "Call parent page function" onclick= ' Parent.window.parent_click (); '/>
<input type= "button" value= "Call this page function" onclick= "Child_click ();"/>
</body>
I hope this article will help you with your JavaScript based Web programming.