开发者

how to know when the DOM of an iFrame is ready again after changing its content?

I'm writing a firefox addon using jquery. I added an iFrame to a page and filled it with another page (allowed due same orign policy).

$('#globalContainer').append('<iframe id="reusable_iframe" src="" width="90%" height="400" name="reusable_iframe"></iframe>');
//....
$('#reusable_iframe').attr('src', link);
//...
var link = $('#reusable_iframe').contents().find(HTMLclass).eq(position).find(searchBy).attr('href');

The problem is, the DOM inside the iFrame isn't finished loading before my access. How开发者_Go百科ever, when I add an alert then it works without any problems:

$('#globalContainer').append('<iframe id="reusable_iframe" src="" width="90%" height="400" name="reusable_iframe"></iframe>');
//....
$('#reusable_iframe').attr('src', link);
//...
alert("wait a sec"); //<-------------------------
var link = $('#reusable_iframe').contents().find(HTMLclass).eq(position).find(searchBy).attr('href');

This problem is very similar to my ajax-problem, which also worked with an alert. how to know when the DOM is ready again after adding a node from ajax I haven't found a solution for both problems...

I tried this one: jQuery .ready in a dynamically inserted iframe but it wasn't working for me...

Thank you all =)


$('#globalContainer').append('<iframe id="reusable_iframe" src="" width="90%" height="400" name="reusable_iframe"></iframe>');
//....
$('#reusable_iframe').attr('src', link);

$('#reusable_iframe').load(function(){
    var link = $('#reusable_iframe').contents().find(HTMLclass).eq(position).find(searchBy).attr('href');

});
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜