Vin*_*ent 22 javascript jquery jquery-events
为什么以下不起作用:
//iframe:
window.parent.$(document).trigger('complete');
//parent window:
$(document).bind('complete', function(){
alert('Complete');
});
Run Code Online (Sandbox Code Playgroud)
而以下IS工作:
//iframe:
window.parent.$('body').trigger('complete');
//parent window:
$('body').bind('complete', function(){
alert('Complete');
});
Run Code Online (Sandbox Code Playgroud)
?
Hac*_*ese 41
跟踪事件的方式,您只能在同一文档上触发或接收事件.
尝试
window.parent.$(window.parent.document).trigger('complete');
Run Code Online (Sandbox Code Playgroud)
Ken*_*ler 11
您可以尝试在父文档中添加触发函数,然后从iframe将其作为常规函数调用.这应该确保您在正确的文档上下文中触发事件.
// In Parent
function triggerComplete () {
$(document).trigger('complete');
}
// In iFrame
window.parent.triggerComplete();
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
29192 次 |
| 最近记录: |