簡體   English   中英

jQuery:創建iframe DOM對象后,綁定LOAD事件

[英]jquery: bind LOAD event after creating a iframe DOM object

我該怎么做呢?

$('#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!');
});

錯別字?

  // ---------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!');
    });
});

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM