使用postmessage刷新iframe的父文档
我有一个greasemonkey 脚本,它打开一个iframe,其中包含来自不同子域的表单作为父页面。
我想在表单提交后刷新 iframe 时刷新父页面
我现在可以在 iframe 刷新时执行一个函数,但无法让该函数影响父文档。
我知道这是由于浏览器安全模型造成的,并且我一直在阅读有关使用 postMessage 在两个窗口之间进行通信的内容,但我似乎无法弄清楚如何用它向父级发送重新加载调用。
任何关于如何做到这一点的建议都会非常有帮助
谢谢
I have a greasemonkey script that opens an iframe containing a form from a different sub-domain as the parent page.
I would like to refresh the parent page when the iframe refreshes after the form submission
I am at the point where I can execute a function when the iframe refreshes, but I cannot get that function to affect the parent document.
I understand this is due to browser security models, and I have been reading up on using postMessage to communicate between the two windows, but I cannot seem to figure out how to send a reload call to the parent with it.
Any advice on how to do that would be very helpful
thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用:
注意“*”表示“任何来源”。如果可能的话,您应该将其替换为目标原点。
在您的父框架中,您需要:
将“my.iframe.org”替换为 iFrame 的来源。 (您可以跳过来源验证,只需非常小心地处理您获得的数据即可)。
Use:
Note the '*' indicates "any origin". You should replace this with the target origin if possible.
In your parent frame you need:
Replace "my.iframe.org" with the origin of your iFrame. (You can skip the origin verification, just be very careful what you do with the data you get).