javascript - How to know if document has loaded -
i have piece of js code needs determine if dom has loaded. know there several ways of executing js code when dom has loaded like:
$(document).ready(function() { ... }); // jquery version document.body.onload = function() { ... } // vanila js way
i looking method looks like
function isdomloaded() { // check if dom loaded or not // return true/false depending upon logic }
ps: update (post answer accept) happen see jquery use same approach check if dom has loaded. take @ implementation of jquery.ready() here
bindready: function() { if ( readybound ) { return; } readybound = true; // catch cases $(document).ready() called after // browser event has occurred. if ( document.readystate === "complete" ) { return jquery.ready(); } ...
function isdomloaded(){ return document.readystate == 'complete'; }
Comments
Post a Comment