IFrame Loaded 事件中的所有内容

发布于 2024-09-13 03:33:43 字数 197 浏览 4 评论 0原文

是否有某种 IFrame 事件仅在每个资源(脚本、图像、样式表、dom)加载时触发?基本上我希望在 IFrame 上显示一个加载图形,并且仅在所有内容都加载到内部时才将其删除,这样用户就看不到所有内容正在加载。

目前我正在使用 $(iframe).ready(function() { ... }); 但这会在加载任何内容之前很早就触发。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

◇流星雨 2024-09-20 03:33:43

您正在寻找 window.onload 事件。

如果任何东西(图像、iFrame 等)完全加载,window.onload 就会触发,这就是为什么大多数人非常不喜欢这个事件。但就你的情况而言,它似乎很合适。

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

非 jQuery

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

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');
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文