A.html包含B.html,B.html点击按钮访问A.html的js方法.
B.HTML源代码:
<html>
<head>
<script type="text/javascript">
function say()
{
alert("child.html--->I'm at child.html");
}
function callParent() {
parent.say();
}
</script>
</head>
<body>
<form id="form1" name="form1" method="post" action="c.php">
<input type="submit" name="a" id="a" value="提交" onclick="callParent()"/>
</form>
</body>
</html>
A.html的代码:
<html>
<head>
<script type="text/javascript">
function say() {
alert("parent.html------>I'm at parent.html");
}
function callChild()
{
//document.frames("myFrame").f1();
myFrame.window.say();
}
</script>
</head>
<body>
<input type=button value="调用child.html中的函数say()" onclick="callChild()">
<iframe name="myFrame" src="child.html"></iframe>
</body>
</html>