可能重复:
Iframe Function Calling From Iframe to parent page javascript function如何从iframe中调用Javascript函数?
我需要从一个iframe运行JavaScript函数(在一个HTML页面),我也跟着我在网上找到的指示,但我不能让这行得通。有任何想法吗?
下面的代码:
<html>
<head>
<script type="text/javascript">
function testFunction()
{
var jsmessage = "Test succeed.";
alert(jsmessage);
return false;
}
</script>
</head>
<body>
<iframe id="myframe" src="iframe.html" height="260" width="620" frameborder="0"></iframe>
</body>
</html>
而这里的Iframe.html的代码:normally.Why你说不能工作
<html>
<body>
<input type="button" onclick="parent.testFunction();" value="Test function">
</body>
</html>
结算这个职位:http://stackoverflow.com/questions/2161388/iframe-function-calling-from-iframe-to-parent-page-javascript-function – kylemac