javascriptjqueryhtmlpreloaderimage-preloader

Page Refresh Preloader Page Position Issue


Hi There I am having a problem with my preloader. If I am say half way down a page and I click a link or page refresh the next page shows at the last position (e.g half way down page as I was on previous page.) I need every page to be at the top. Here is my code:

$(window).load(function(e){ 
    e.preventDefault();
    $('#status').fadeOut('slow'); 
    $('#preloader').fadeOut('slow'); 
    $(function(){
      $(this).scrollTop(0);
        setTimeout(function(){
        $('html, body').css({ "overflow-y":"auto"});}, 500);
    });       
});

Solution

  • Hi found the answer based on this Reload browser does not reset page to top

    scrollTop function wasn't working properly here is working example

        $(window).load(function(e){ 
        e.preventDefault();
        $('#status').fadeOut('slow'); 
        $('#preloader').fadeOut('slow'); 
        $(function(){
            $('html').animate({scrollTop:0}, 1);
            $('body').animate({scrollTop:0}, 1);
            setTimeout(function(){
            $('html, body').css({ "overflow-y":"auto"});}, 500);
            });
    
    });