In the Window Load event, we can delay processing so that some events can be handled when the page loads.
The code is as follows |
Copy Code |
(function fn () { Fn.now = +new Date; $ (window). Load (function () { if (+new date-fn.now < 1000) settimeout (FN, 1000); Do something }); })(); |
If we want to perform a bit of latency to display a mask layer (just for example) when the Load event executes, refer to the next CSS mask code. As follows:
The code is as follows |
Copy Code |
(function fn () { Fn.now = +new Date; $ (window). Load (function () { if (+new Date-fn.now < 3000) settimeout (FN, 3000); $ ("#mask"). Show (); }); $ ("#mask"). Hide (); })(); |
Here's a look at a settimeout and jquery implementation of the delay loading
code is as follows |
copy code |
<div class= "Toolbarframe" style= "Display:none;" ><a href= "http://www.111cn.net" target=_blank><a class= "Bigad_close" > Close </a></div> <script> $ (function () { SetTimeout (' $ (' Toolbarframe '). Show ("Slow") ', 2000; $ (". Bigad_close"). Click (function () { $ (". Toolbarframe"). Hide ("slow"); } //settimeout (' $ ('. Toolbarframe '). Hide ("slow") ', 12000); }); </script> |