从Iframe到父文档触发自定义事件 [英] Trigger Custom Event From Iframe To Parent Document

查看:227
本文介绍了从Iframe到父文档触发自定义事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在iframe中触发自定义事件并从父文档中检测到它时遇到了一些麻烦。
iframe和父文档都有相同的来源(相同的协议,相同的主机,相同的端口)。

I am having some trouble to fire a custom event inside an iframe and detect it from the parent document. Both iframe and parent document have the same source (same protocol, same host, same port).

有什么建议吗?

推荐答案

这有效:

parent.$('body').trigger('eventName');

在iframe中触发的事件将在父文档中检测到。

the event triggered inside the iframe will be detected in the parent document.

这篇关于从Iframe到父文档触发自定义事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆