How to delay the onLoad event that fires in the browser?

I am trying to defer an onLoad event that fires. Is there any way to postpone this event strictly using client side javascript?

+4
source share
2 answers

If you put a script tag at the end of the body , for example:

 <body> ... <script> setTimeout(function(){ //deferred onload }, 2000); </script> </body> 

The function will be executed after 2 seconds in this case

+8
source

There is no reason to delay the onload event. Maybe you want to use window.load instead?

 $(window).load(function(){ //your code here }); 
-2
source

All Articles