ScrollTop after the page has already been loaded

1

I want to do scrollTop after I click a button. Only not on the page that I am, but on the page that will open.

My HTML:

<a href="/clinicas" class="saibaMais cp margin-top-40 margin-bottom-25 f-left unidadesClick">
    <div class="saibaMaisText">saiba mais</div>
    <div class="saibaMaisHover">saiba mais</div>
</a>

And my Jquery:

$('.unidadesClick').click(function () {
  $('html, body').stop().animate({
   scrollTop: '620px'
   }, 700);
});

As it is, it does the ScrollTop on the same page. How do I make an effect when I'm inside% / clinics ?

    
asked by anonymous 02.12.2014 / 11:58

1 answer

3

Verify that you are accessing a URL that contains /clinicas :

$(function(){
    //coloque este código onde quer que você tenha o código que verifica que o DOM está pronto
    if (window.location.toString().indexOf('/clinicas') > 0) {
        $('html, body').stop().animate({
             scrollTop: '620px'
        }, 700);
    }

});  

This should solve your problem.

Your jQuery is scrolling on the page before accessing as it is written: when you click on the element .unidadesClick , scrollTop on the 620px of <body> , when you want to scroll when you are on the page /clinicas .

    
02.12.2014 / 12:28