我有 2 个问题:
我怎么知道框架的内容准备好/加载(as
$(document.ready())
)?我如何知道弹出 (
window.open()
) 内容已准备好/已加载 (as$(document.ready())
)?
谷歌说这可能会有所帮助$("iframe").load()
,但我不明白如何
我有 2 个问题:
我怎么知道框架的内容准备好/加载(as $(document.ready())
)?
我如何知道弹出 ( window.open()
) 内容已准备好/已加载 (as $(document.ready())
)?
谷歌说这可能会有所帮助$("iframe").load()
,但我不明白如何
DEMO — iframe
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.
DEMO — window.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".
The load callback will be called when the iFrame will be load :
$("#iframe-id").load(function(){
//The iFrame content is loaded
})