0
Ich habe eine einzelne Seite Website gemacht (+ einzelne Beiträge) und ein Menü, das auf Ankerpunkt scrollt, wenn Sie auf sie:ausgeblendet Anker in URL beim Scrollen zu anchor
if (window.location.hash) scroll(0, 0);
setTimeout(function() { scroll(0, 0); }, 1);
$(function() {
$('.scroll').on('click', function(e) {
e.preventDefault();
$('html, body').animate({
scrollTop: $($(this).attr('href')).offset().top
}, 1000, 'swing');
});
if(window.location.hash) {
$('html, body').animate({
scrollTop: $(window.location.hash).offset().top
}, 1000, 'swing');
}
});
var $root = $('html, body');
$('a').on('click', function(event){
var hash = this.hash;
if (hash && this.href.slice(0, -hash.length-1) == location.href.slice(0, -location.hash.length-1)) {
$root.animate({
scrollTop: $(hash).offset().top
}, 'swing', function() {
location.hash = hash;
});
return false;
}
});
Aber ist es auch möglich zu halten Diese Funktion wie sie ist, aber verstecken Sie die #anchor in der URL?
Haben Sie versucht, einfach die Zeile entfernen, die explizit den Hash nach der Animation _sets_ ...? – CBroe