3

我有 2 个问题:

  • 我怎么知道框架的内容准备好/加载(as $(document.ready()))?

  • 我如何知道弹出 ( window.open()) 内容已准备好/已加载 (as $(document.ready()))?

谷歌说这可能会有所帮助$("iframe").load(),但我不明白如何

4

2 回答 2

2

DEMOiframe

The problem with using load() is the iframe may have already loaded before the jQuery has run, thus not triggering the function. One way around this would be to initially load nothing in the iframe (about:blank), then using jQuery to change the src attribute to get the iframe to point to the desired location.

DEMOwindow.open   (Disable your popup blocker for this demo.)

I'm not sure whether ready() can be used cross-domain. When loading a popup/iframe on the same domain, a script on the child page can be used to report back to the parent window that it is "ready".

于 2012-11-04T19:19:14.583 回答
1

The load callback will be called when the iFrame will be load :

$("#iframe-id").load(function(){
    //The iFrame content is loaded
})
于 2012-11-04T18:14:43.880 回答