jQuery on link click to enable a loading graphic

208 Views Asked by At

So I have this script that is used to show this loding graphic while a page loads.

    $(window).load(function() { // makes sure the whole site is loaded
        $("#status").fadeOut(); // will first fade out the loading animation
        $("#preloader").delay(100).fadeOut("fast"); // will fade out the white DIV that covers the website.
    })

This shows up immediately on the page load. Any idea how to make this show on a page exit? So to the user its consistent from click to load?

1

There are 1 best solutions below

0
4b0 On

Use unload.

$(window).unload(function() {
        $("#status").fadeOut(); 
        $("#preloader").delay(100).fadeOut("fast"); 
});