0

I am using this lovely jquery plugin

http://www.gayadesign.com/diy/queryloader2-preload-your-images-with-ease/

It loads your whole website including images before displaying it. It works perfectly well. What I wanted to do was add a small skip button which would skip the script and jump to the page without preloading for people who are too impatient.

//create the skip button
this.skipbutton = $("<div id='skip'><a href='#' id='skipbut'>SKIP</a></div>").css({
    height: 20 + "px",
    marginTop: "-" + (this.parent.options.barHeight / 2) + "px",
    Color: this.parent.options.barColor,
    width: "0%",
    position: "absolute",
    top: "70%",
    left: "50%"
}).appendTo(this.container);

I wanted to now know how to skip it ..I didnt think stop() function would work for this?

//skip function
$("#skipbut").click(function(){
        //insert code here
});

SO Any help in the right direction would be highly appreciated. Thank you so much in advance :-)

4

2 回答 2

0

One possible solution is you can set local storage for that and reload your page:

$("body").on('click','#skipbut',function(){       
     localStorage.setItem("load","true");
     location.reload();
});

And check it when you are loading your plugin , something like this :

$(document).ready(function () {
     if( localStorage.getItem("load")=="true" ){             
         // if local storage is set skip the loader 
         localStorage.removeItem("load");
     }else{
         // if localstorage is not present use the loader
         $("body").queryLoader2();
     }
});

Hope it shed some light.

于 2013-11-11T13:26:50.200 回答
0

I found a very simple solution, though I will confess its not the ideal one but I had to move quickly

I made another clone of the page without the preloader and attached a redirect action to the skip button.

SO technically it loaded a clone of the page without the preloader. Works fine but not the way I would have wanted it too.

于 2013-11-12T11:11:25.313 回答