After a day, I finally found a solution on the Internet.
Note: The problem is that the sub-PAGE method is called on the parent page .....
Parent page: parent.html
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> parent </title>
<Script>
Function parentFunction (){
Alert ('function in parent ');
}
Function callChild (){
Child. window. childFunction ();
/*
Child is the name attribute value of iframe,
Cannot be id, because the id in FireFox cannot get the iframe object
*/
}
</Script>
</Head>
<Body>
<Input type = "button" name = "call child" value = "call child" onclick = "callChild ()"/>
<Br/>
<Iframe name = "child" src = "./child.html"> </iframe>
</Body>
</Html>
Subpage: child.html
Copy codeThe Code is as follows:
<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Transitional // EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<Html xmlns = "http://www.w3.org/1999/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> child </title>
<Script>
Function childFunction (){
Alert ('function in child ');
}
Function callParent (){
Parent. parentFunction ();
}
</Script>
</Head>
<Body>
<Input type = "button" name = "call parent" value = "call parent" onclick = "callParent ()"/>
</Body>
</Html>
You can modify the corresponding code as needed .......