Check if webpage is completely loaded

时间:2016-07-11 21:34:49

标签: javascript angularjs webpage

I need to make a Ajax call after my webpage is completely loaded , How do i check whether my webpage is completely loaded .

Is document.ready is only solution .

2 个答案:

答案 0 :(得分:1)

If by completely loaded, you mean that all the resources of the page are loaded too (like images, fonts, etc.), then, window.onload is where you need to tie your handler.

If you only care about when the browser finishes constructing your DOM, you need to add the listener to DOMContentLoaded event.

答案 1 :(得分:0)

If you want something similar to jQuery's document-ready event (indicating that all of the necessary references have been loaded and that the window is ready), you could probably use something like :

angular.element(document).ready(function () {
        // Your document is ready, place your code here
});