1. The iframe subpage calls the parent page js function The subpage only needs to write window.praent to call the parent page function. For example, to call the a() function, it is written as:
window. parent.a();
The child page takes the value in the tag in the parent page. For example, the id of the tag is "test", then:
window.parent.document.getElementById("test").value;
jQuery method For:
$(window.parent.document).contents().find("test").val();
But I found it under the chrome browser This method is invalid! After checking for a long time, I found out that in chrome 5, window.parent cannot run in the file:// protocol, but after it is released, it can run in the http:// protocol. This method supports IE and Firefox browsers.
2. The iframe parent page calls the child page js function
This is a little more complicated. The following method supports IE and Firefox browsers:
document.getElementById('ifrtest').contentWindow.b();
The child page takes the value in the tag in the parent page. For example, the tag's id is "test", then:
document.getElementById("test").value;
Note: ifrtest is the id of the iframe, and b() is the subpage js function. The contentWindow attribute is the window object where the specified frame or iframe is located, and can be omitted under IE.