0
當我做了一個單頁網站(+單柱)和滾動到他們,當點擊anchorpoints菜單:隱藏錨滾動到anchorpoint
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;
}
});
但是,它也可以保持這個函數是這樣的,但是將#anchor隱藏在URL中?
您是否嘗試過簡單地刪除該動畫後明確_sets_哈希行...? – CBroe