4
$(window).load(function() {
$('a.scroll').each(function() {
var id = $(this).attr('href');
if (id.match('^#')) {
var target = $(id).offset().top - 65;
var title = $(this).attr('title');
$(this).on('click tap', function() {
$('body').animate({
scrollTop: target
}, 1000);
history.pushState({
foo: title
}, title, id);
return false;
});
}
});
});
Same Page
<a href="pecas-servicos#qualidade" class="scroll" title="{!! trans('master.menu.qualidade')">Qualidade</a>
Other Page
<a href="pecas-servicos/contato#qualidade" class="scroll" title="{!! trans('master.menu.qualidade')">Qualidade</a>
When I am on the HOME page and I click on LINK it works to scroll to the section I clicked.
But if I am on another page the same does not happen. It even goes to HOME, however, descends to the bottom page.
these other pages are loaded inside the home ?
– Thiago Friedman
No. Other independent pages.
– Diego Souza
take a look and see if this can help you: http://stackoverflow.com/questions/3163615/how-to-scroll-html-page-to-given-anchor-using-jquery-or-javascript
– Thiago Friedman
It doesn’t work like that. It goes to the bottom of the page too. But if I give a enter in the address bar it goes to the right session... can not understand.
– Diego Souza
I don’t know if you’ve solved it yet and I know it has nothing to do with the problem, but why wait for the
.load
instead of$.ready
?– Guilherme Nascimento
Brother, what unnecessary stuff to be correcting Uppercase or Lowercase in the posts of 1930...
– Diego Souza
Are you talking about FRIENDLY URL? have moved your htaccess (there are 3 languages independent of the hosting server) to forward the site ... or already used <NAME>? and see http://www.w3schools.com/tags/att_a_name.asp
– KingRider