简体   繁体   中英

Html preloader - delay page load

I need some help with my new template :). Before the webpage loads I want to show a preloader gif. I done it, however it shows just a little, because the page loads very fast. So I would like to delay the page (with 2 seconds, as an exemple), without affecting the preloader, so it (the preloader) would appear for 2 seconds, so until the page loads.

For whatever reason u want it its done using setTimeout here is the code

jQuery(document).ready(function ($) {
    $(window).load(function () {
        setTimeout(function(){
            $('#preloader').fadeOut('slow', function () {
            });
        },2000); // set the time here
    });  
});

jsfiddle http://jsfiddle.net/harshdand/593Lqqnm/2/

You Can Just use delay(); jquery function to add dealy to Preloader

$(document).ready(function () {
  $(window).load(function(){
  $('#preloader').delay(3000).fadeOut();
 });
});

it's a sample

<script>
    setTimeout(function () {
        $('.loader-container').fadeToggle ();
    },3500);
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM