<script> function a(){alert('abc')}</script><iframe>
<html>
<script>
function b()
{
window.parent.a();
}
</script>
<body onload="b()">
</body>
</html>
</iframe>魷后一直出现: Uncaught TypeError: Object [object global] has no method ajavascript
<html>
<script>
function b()
{
window.parent.a();
}
</script>
<body onload="b()">
</body>
</html>
</iframe>魷后一直出现: Uncaught TypeError: Object [object global] has no method ajavascript
Samba
检查一下你a函数的作用域是不是在全局,即没被任何function包住
Samba
<html>
<script>
function b()
{
window.parent.a();
}
</script>
<body onload="b()">
</body>
</html>
jquery方法:
1)在iframe中查找父页面元素的方法:(同理class)
$('#id', window.parent.document)2)在iframe中调用父页面中定义的方法和变量:
parent.method
parent.value3)
在父窗口中操作 选中IFRAME中的所有输入框: $(window.frames["iframeSon"].document).find(”:text”);
在IFRAME中操作 选中父窗口中的所有输入框:$(window.parent.document).find(”:text”);js方法:
父窗口操作IFRAME:window.frames["iframeSon"].document
IFRAME操作父窗口: window.parent.document