Execute JS function after some time of page load
Use setTimeout
instead, as it is called only once after the pause:
setTimeout(myFunc, 3000);
The onload event fires at the end of the document loading process. At this point, all of the objects in the document are in the DOM, and all the images, scripts, links and sub-frames have finished loading, After
onload
you can usesetTimeout
to delay your function execution..
var myFunc = function() {
alert('After 3 seconds of page load!');
}
window.onload = function() {
setTimeout(myFunc, 3000);
}