主窗口中的代码:
<script
type="text/javascript">
</script>
<iframe id="test" name="test" src="testb.html"
width="200" height="300" style="border:3px solid
#333;"></iframe>
<input type="button"
value="执行iframe中的函数"
Iframe中的代码:
<script
type="text/javascript">
</script>
<input type="button" value="执行主窗口中的函数"
onclick="window.parent.gogo()" />
window.frames['test'].gogo() 也可以写成 window.frames['test'].window.gogo(),但window.frames['test'] != window.frames['test'].window
同理:
window.frames['test'].window == document.getElementByIdx_x('test').contentWindow
window.frames['test'] == document.getElementByIdx_x('test').contentWindow
在ie6 ie7 ie8 firefox3.6 chrome中测试通过