在我的網站仍在工作:http://i333180.iris.fhict.nl/p2_vc/的Javascript smoothscroll不工作
沒有爲導航下行TE網頁上的按鈕,動作是即時的,但平滑滾動是好得多。
所以,我谷歌周圍,嘗試了很多,我發現最短的腳本是這樣的: 但我無法得到它的工作。
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
編號:https://css-tricks.com/snippets/jquery/smooth-scrolling/
這是我如何添加到我的代碼
之間<head>
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script>
$(function() {
$('a[href*=#]:not([href=#])').click(function() {
if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
var target = $(this.hash);
target = target.length ? target : $('[name=' + this.hash.slice(1) +']');
if (target.length) {
$('html,body').animate({
scrollTop: target.offset().top
}, 1000);
return false;
}
}
});
});
</script>
</head>
按鈕:
<body>
<a id='button_down' href='#section' onclick="document.getElementById('moodvideo').pause()"><img src='scroll.png' alt='Scroll'></a>
</body>
我考察的例子給出現場巫婆並將其添加以同樣的方式對我的HTML。 參考檢查鏈接:https://css-tricks.com/examples/SmoothPageScroll/ ,但我不能讓它的工作..
另外,我有一個其他腳本,女巫需要同樣的動作,視頻結束後。 腳本現在是:
<script>
function videoEnded() {
window.location.href="#section";
}
</script>
這必須做同樣的事情;很好地滾動。
我希望我解釋它可以理解,如果沒有,我想再試一次。 問候
編輯腳本心不是添加到在線網站因爲劇本心不是工作是,如果它將使easer我可以在線添加。
更新網站在線與不工作的腳本