jQuery scroll does not work in chrome do not go back to previous page

-1

I have this code that works fine (just scroll down) in firefox and chrome, but if you then load the browser 'back' (chrome) it does trigger in> load page without me doing scroll . In Html I have:

'<body onunload="">...'

js.js

$(document).ready(function() {

window.scrollTo(0, 0); // ir logo para topo no load da pagina para evitar
                       // que faça trigger à animação sem eu fazer scroll

.......

$(window).scroll(function() {
        if ($(window).scrollTop() > 10){
            var href = $('.toWork').attr('href');
            $('#wrapper').animate({
                "margin-top": "-1000px"
            }, 800, function(){
                window.location=href;
            });
        }
    });
})
    
asked by anonymous 04.09.2014 / 17:48

2 answers

0

This behavior depends on the browser and jQuery version you are using (1.4 and higher work differently than older versions).

There was a discussion about this a while ago in Stackoverflow, I do not know if their workaround will work for you, because the answer is too old, but just in case, make sure you're using the latest version of jQuery.

    
04.09.2014 / 17:58
0

You should probably be trying to load jQuery from Google in the link:

src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"

ThiscausesChrometonotrunthescriptofanunsafepageonasecurepage.

WhenIhadthisproblemIchangedfromhttptohttpsandrannormal.

src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"
    
20.02.2015 / 12:44