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

六眼飞鱼酱① 提交于 2019-12-19 02:27:45

问题


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

Any thoughts?


回答1:



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





回答2:


Try out .load() instead.

$(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/




回答3:


Using javascript

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



回答4:


You can read more about it here. https://github.com/codef0rmer/learn.jquery.com/blob/master/content/jquery-basics/document-ready.md



来源:https://stackoverflow.com/questions/9630904/how-to-detect-if-a-page-has-fully-rendered-using-jquery

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!