iframe可能调用父级功能,即使它们不在同一个域? 我的实际做法电梯的时候都没有在同一个域中的安全错误:IFrame调用父功能
<script>
function test()
{ alert('wow');
}
</script>
<iframe src="...."></iframe>
而且iframe中,我会做到这一点:
<script>
function fin()
{ top.test(); }
</script>
非常感谢:)
iframe可能调用父级功能,即使它们不在同一个域? 我的实际做法电梯的时候都没有在同一个域中的安全错误:IFrame调用父功能
<script>
function test()
{ alert('wow');
}
</script>
<iframe src="...."></iframe>
而且iframe中,我会做到这一点:
<script>
function fin()
{ top.test(); }
</script>
非常感谢:)
您不能直接调用函数(由于same origin policy,但您可以使用postMessage
(如在回答this question描述),并有一个事件侦听器中调用该函数响应。
你如果你需要支持Internet Explorer 7和更低版本,会有点out of luck
这是一个解决方案吗? http://easyxdm.net/wp/ – 2012-03-14 11:24:37
Dupe http://stackoverflow.com/questions/4122422/cross-domain-hash-change-communication – tkone 2012-03-14 11:33:23