在iframe的父窗口中触发事件 [英] Trigger events in iframe's parent window

查看:391
本文介绍了在iframe的父窗口中触发事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么以下不起作用:

//iframe:
window.parent.$(document).trigger('complete');

//parent window:
$(document).bind('complete', function(){
  alert('Complete');
});

当以下IS工作时:

//iframe:
window.parent.$('body').trigger('complete');

//parent window:
$('body').bind('complete', function(){
  alert('Complete');
});

推荐答案

跟踪事件的方式,您只能触发或接收同一文档上的事件。

The way events are tracked, you can only trigger or receive events on the same document.

尝试

window.parent.$(window.parent.document).trigger('complete');

这篇关于在iframe的父窗口中触发事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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