使用 Javascript 将消息从页面传递到父框架,而不使用 HTML 5
我有以下场景,其中有一个页面“parentPage.html”,其中包含一个 iFrame“parentFrame”,该 iFrame 托管页面“childFrame.html”。 “childFrame.html”包含另一个名为“childFrame”的框架,并将该页面称为“sample.html”。现在,我想从“sample.html”发送消息并在“parentPage.html”或“childFrame.html”接收它。
我尝试使用 Porthole 库。然而,它并不能帮助我解决这个特定的场景。另请注意,上述页面不必位于同一域中。
如果您能让我知道如何解决这个特定问题,那就太好了。
提前致谢。
I have the following scenario where I have a page say “parentPage.html”, which contains an iFrame say “parentFrame” which hosts the page “childFrame.html”. “childFrame.html” contains another frame called “childFrame” and calls the page “sample.html”. Now, I want to send a message from “sample.html” and receive it at “parentPage.html” or “childFrame.html”.
I've tried using the Porthole library. However, it doesn't help me in solving this particular scenario. Also, please note that the above mentioned pages need no be in the same domain.
It would be great if you could let me know on how I can solve this particular problem.
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
有一种解决方法,称为跨框架技术,请参阅链接以了解此技术 http://www.julienlecomte.net/blog/2007/11/31/
There is a work around for this which is called crossframe technique please see the link to understand this technique http://www.julienlecomte.net/blog/2007/11/31/
尝试按照
example.html
中的流程运行 JavaScript:或者
,您也可以调用父框架或顶部框架中的函数。
Try run JavaScript as flows in
example.html
:or
also, you can call functions in parent frame or top frame.