【发布时间】:2011-08-12 21:49:13
【问题描述】:
有没有人知道有没有这样的事情?
我有一个使用$.ajax() 插入的 iframe,我想在 iframe 中的内容完全加载后做一些事情:
....
success: function(html){ // <-- html is the IFRAME (#theiframe)
$(this).html(html); // $(this) is the container element
$(this).show();
$('#theiframe').load(function(){
alert('loaded!');
}
....
它有效,但我看到 IFRAME 加载了两次(警报也显示了两次)。
【问题讨论】:
-
在将 iframe 附加到 DOM 之前尝试设置 iframe 的 src。这应该可以防止加载事件触发两次。
标签: javascript ajax jquery iframe