Collection of mutual calling methods between iframe parent window and child window_javascript skills
WBOY
Release: 2016-05-16 18:13:45
Original
997 people have browsed it
1. The parent window calls the iframe child window method 1. HTML syntax: 2. The parent window calls the child window: myFrame.window.functionName(); 3. The child window calls the parent window: parent.functionName(); Simply put, it is the variable or function called in the child window Just add parent. 4. Parent window page source code:
2. How to call each other between iframe parent window and child window 1. How to use in IE: The parent window calls the child window: iframe_ID.iframe_document_object.object_attribute = attribute_value Example: onClick="iframe_text.myH1.innerText='http://www.pint.com';" The child window calls the parent window: parent.parent_document_object.object_attribute = attribute_value Example: onclick="parent.myH1.innerText='http://www.pint.com';" 2. How to use it in Firefox : The above works fine under IE, but not under Firefox. Under Firefox, the calling method should be as follows: The parent window calls the child window: window.frames["iframe_ID"].document.getElementById("iframe_document_object").object_attribute = attribute_value Example: window.frames[" iframe_text"].document.getElementById("myH1").innerHTML= "http://hi.jb51.net"; The child window calls the parent window: parent.document.getElementById("parent_document_object").object_attribute = attribute_value Example: parent.document.getElementById("myH1").innerHTML = "http://jb51.net"; 3. Complete example test.htm
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn