2013-08-17 8 views
5

コンテンツを1つのフレームから別のフレームにコピーしています。私のコードはMozilla Firefoxで動作していますが、Google Chromeでは動作しません。誰かが私がどこに間違って行ったか教えてくれますかGoogle ChromeでJquery Iframe onloadイベントが実行されていません

この部分は、Googleのクロムに実行していない:

$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); 
}); 

答えて

8

それは、ロードイベントが発生あまりにも速いかのように、追加表示されます。

$('#frame1').load(function(e){ 

}); 
以下


は私のコードブロックでありますiframeをDOMに挿入する前のロードリスナー:

$('<iframe />',{ id: 'frame1', 
       class:'myframe', 
       height: 600, 
       width: "100%" 
    }).load(function(e){ 
    console.log("Executed #frame1 load");   

    }).appendTo(uxcontainerPath); 
+0

私は新しいことを学びました。このすばらしい答えをありがとう。 – madi

関連する問題