The use of IFRAME, may involve the parent-child window between the values and methods of mutual invocation, has been a bit confused, and did not deliberately to find out, these two days to work, can not have to put this all figured out. Actually very simple, just a few uses, a few lines of code just.
The JS method of calling the parent window in a child window:
Copy Code code as follows:
Parent.changebtntitle (' Tzgg ');
A parent window may have several child windows with similar function behavior, and the component in the child window will invoke the same or similar object or method, then write the method in the parent window and pass the parameters to achieve different effects.
The parent window obtains an object from the child window:
First you get the IFrame object for the child window, such as:
Copy Code code as follows:
var framename = window.frames["Frameid"]
Then you get the document value for the child window, and then you can call the object in the child window. To avoid repeated writing when used in a parent window, you might write a method:
Copy Code code as follows:
Getsubwindowobj = function (modulename) {
return window.frames["iframe" +modulename].document.getelementbyid ("moreorless" +modulename);
}
Here only a parameter, because my Iframeid and child window of the object ID name of the law, just pass in a parameter splicing can be hungry.
Similarly, the child page calls the element of the parent page, and you can use the following code:
Copy Code code as follows:
Parent.window.document.getElementById (' Parentmenu ');
Shorthand
Parent.document.getElementById (' Parentmenu ');