2011-02-25 2 views
0

어떻게하면 되나요?jquery : iframe DOM 객체를 생성 한 후 LOAD 이벤트를 바인딩하십시오.

$('#divToInsert').html('<iframe id="outputPage" src="/Folder/webpage.aspx" width="90%" height="600" frameborder="0" scrolling="yes" style="overflow-x: hidden"><p>WARNING: Your browser does not support iframes. Please contact your adminstrator for assistance.</iframe>'); 
$('#outputPage').unbind('load'); 
$('#outputPage').bind('load', function() { 
    alert('done!'); 
}); 

답변

0

오타?

// ---------v---------------there's a "t" that shouldn't be there 
$('#outputPaget').bind('load', 

수정 후 작동합니다.

DOM도로드되어 있는지 확인하십시오.

http://jsfiddle.net/gz2eS/

유래에
$(function() { 
    $('#divToInsert').html('<iframe id="outputPage" src="/Folder/webpage.aspx" width="90%" height="600" frameborder="0" scrolling="yes" style="overflow-x: hidden"><p>WARNING: Your browser does not support iframes. Please contact your adminstrator for assistance.</iframe>'); 
    $('#outputPage').unbind('load'); 
    $('#outputPage').bind('load', function() { 
     alert('done!'); 
    }); 
}); 
+0

typeo. 죄송합니다. 여전히 작동하지 않습니다. –

+0

@Martin : DOM이로드되어 있습니까? 내 대답에 jsFiddle 예제를 게시했습니다. 코드가 작동합니다. 'divToInsert' ID가 정확한지 확인하십시오. – user113716

+0

IE 8이 아닌 mozilla에서 작동합니다. –

관련 문제