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?
This part is not executing in Google chrome :
$('#frame1').load(function(e){
});
Below is my code block:
$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);
});
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?
This part is not executing in Google chrome :
$('#frame1').load(function(e){
});
Below is my code block:
$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);
});
Share
Improve this question
asked Aug 17, 2013 at 8:57
madimadi
5,6625 gold badges39 silver badges48 bronze badges
1 Answer
Reset to default 8It 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);