![](/img/trans.png)
[英]Calling JavaScript from SSRS Report is not working when the report is hosted in Iframe with domain different than that of Parent Page
[英]execute javascript function in a another iframe when parent is from different domain
页面A.com有2个iframes B.com/page1和B.com/page2 。 这是A.com的代码:
<html><body>
<iframe src="b.com/page1" name="iframe1" id="iframe1">
<iframe src="b.com/page2">
</body></html>
我想从B.com/page2在B.com/page1上执行js功能。 当父来自同一个域而不是跨域方案时,以下两个示例都很有效:
parent.window.frames['iframe1'].SomeFunction(args);
要么
parent.document.getElementById('iframe1').contentWindow.SomeFunction(args);
有什么办法吗?
代替
parent.window.frames['iframe1'].SomeFunction(args);
采用
parent.frames['iframe1'].SomeFunction(args);
您可以遍历可以引用的任何窗口的frames
集合,但在这种情况下,您尝试遍历parent
的递归window
属性(即窗口)。 这是不允许的。
不,浏览器不允许根本不在同一域的iframe之间进行交互。
正如Aaron已经告诉过你的那样,浏览器不允许这样做,但有很多方法可以解决它。 你需要创建一个小黑客。 Eugene Gladyshev 在他的博客上有一篇文章 。
正如Aaron所说,不允许在iframe之间进行交互,但你应该看一下easyXDM,它有助于javascript中的跨域通信:
以下是您可能正在寻找的示例:
http://easyxdm.net/wp/2010/03/17/sending-and-receiving-messages/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.