开发者

Everything in an IFrame Loaded event

开发者 https://www.devze.com 2023-01-10 13:24 出处:网络
Is there some sort of event for IFrames that only fires when every resource (script, image, stylesheet, dom) has loaded? Basically I want to开发者_如何学运维 have a loading graphic displayed over the

Is there some sort of event for IFrames that only fires when every resource (script, image, stylesheet, dom) has loaded? Basically I want to开发者_如何学运维 have a loading graphic displayed over the IFrame and only remove that when everything is loaded inside so the user doesn't see everything loading.

Currently I am using $(iframe).ready(function() { ... }); but this fires very early before anything has loaded.


You are looking for the window.onload event.

window.onload fires if anything (images, iFrames, etc.) was completly loaded, that is why most guys dislike this event pretty much. But in your case, it seems to fit.

$(window).load(function(){
   alert('fired');
});

non-jQuery

window.onload = function(){
   alert('fired');
};
0

精彩评论

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