Greetings, community. The following code adds a loaded class to body . How to change it so that the class is added two seconds after the condition is met (here - the DOM generation).
function domReady() { document.body.className += " loaded"; } if (document.addEventListener) { document.addEventListener("DOMContentLoaded", function() { document.removeEventListener("DOMContentLoaded", arguments.callee, false); domReady(); }, false); } else if (document.attachEvent) { document.attachEvent("onreadystatechange", function() { if (document.readyState === "complete") { document.detachEvent("onreadystatechange", arguments.callee); domReady(); } }); }
setTimeout(function (){domReady();}, 2000);you can even write shortersetTimeout(domReady, 2000);- so it should also work - Ivan Karaman