javascript 如何使用jQuery检测页面是否已完全呈现?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9630904/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-26 07:16:54  来源:igfitidea点击:

How to detect if a page has fully rendered using jQuery?

javascriptjquerywebpage

提问by Propeller

When using $(document).ready(functioon(){alert("Loaded.")});it pops up the alert box that says "Loaded." even beforethe page has fully loaded (in other words there're loading still going on like images).

使用时$(document).ready(functioon(){alert("Loaded.")});会弹出提示框,提示“已加载”。即使页面完全加载之前(换句话说,加载仍然像图像一样)。

Any thoughts?

有什么想法吗?

回答by Sudhir Bastakoti


$(window).on('load', function() {
    //everything is loaded
});


回答by Kristoffer Svanmark

Try out .load() instead.

试试 .load() 代替。

$(document).load(function () {
    alert('Loaded');
}

The load event is sent to an element when it and all sub-elements have been completely loaded. http://api.jquery.com/load-event/

当一个元素和所有子元素都被完全加载时,加载事件被发送到一个元素。 http://api.jquery.com/load-event/

回答by Gowri

Using javascript

使用 JavaScript

   window.onload = function () { alert("loaded"); }