jQuery scroll does not work on Chrome in the rewind to previous page

Asked

Viewed 923 times

-1

I have this code that works well (just scroll down) in firefox and Chrome , but if you then click the 'backward' browser (Chrome) it does Trigger just in the load page without me do 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;
            });
        }
    });
})

2 answers

0

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

There was a discussion on this a while ago at Stackoverflow, I don’t know if their workaround will suit you, because the answer is too old, but just in case, make sure you’re using the latest version of jQuery.

  • I do, 1.11.1. Isn’t there a way to, with code, turn this around? Based on the code I posted

0

You probably are trying to load jQuery from Google on the link:

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

This causes Chrome not to run script from an unsecured page on a secure page.

When I had this problem I changed from http for https and rotated normal.

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

Browser other questions tagged

You are not signed in. Login or sign up in order to post.