Jquery Iframe onload事件未在Google Chrome上执行 [英] Jquery Iframe onload event is not executing on Google chrome
本文介绍了Jquery Iframe onload事件未在Google Chrome上执行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在将内容从一个帧复制到另一个帧。我的代码在Mozilla Firefox中运行,但它在Google Chrome中无效。有人可以告诉我哪里出错吗?
I am copying the content from one frame to the other. My codes are working in Mozilla Firefox but it is not working in Google Chrome. Can someone tell me where I went wrong?
此部分未在Google Chrome中执行:
This part is not executing in Google chrome :
$('#frame1').load(function(e){
});
以下是我的代码块:
$headContent = $("#mainframe").contents().find("head").html();
$bodyContent = $("#mainframe").contents().find("body").html();
$('<iframe />');
$('<iframe />',{ id: 'frame1',
class:'myframe',
height: 600,
width: "100%"
}).appendTo(uxcontainerPath);
$('#frame1').load(function(e){
console.log("Executed #frame1 load"); //this console line is not executed in chrome
$(this).contents().find('html').append('<head></head>');
$(this).contents().find('head').append($headContent);
$(this).contents().find('body').append($bodyContent);
});
推荐答案
好像加载事件发生得太快,在将iframe注入DOM之前添加load-listener:
It appears as if load-event fires too quick, add the load-listener before you inject the iframe into the DOM:
$('<iframe />',{ id: 'frame1',
class:'myframe',
height: 600,
width: "100%"
}).load(function(e){
console.log("Executed #frame1 load");
}).appendTo(uxcontainerPath);
这篇关于Jquery Iframe onload事件未在Google Chrome上执行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文