我想在父窗口中侦听从iframe触发的自定义事件。我甚至试图在文档和窗口上绑定事件但是没有成功。
主要JS:
$(document).bind('EVENT_ANIMATION_COMPLETE', onAnimationComplete);
在iframe中使用JS:
$(document).trigger('EVENT_ANIMATION_COMPLETE');
答案 0 :(得分:2)
因为iframe中的document
不等于父级中的document
。
有几种方法可以做到,一种方法是
parent.$(parent.document).trigger("EVENT_ANIMATION_COMPLETE");