Ancora lavorando sul mio sito: http://i333180.iris.fhict.nl/p2_vc/Javascript smoothscroll non funziona
C'è un pulsante per spostarsi verso il basso TE pagina, l'azione è immediata ma scorrimento continuo è molto più bello.
Così, ho cercato su google, e lo script più breve che ho trovato è questo su: Ma non riesco a farlo funzionare.
$(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;
}
}
});
});
Rif: https://css-tricks.com/snippets/jquery/smooth-scrolling/
Ecco come ho aggiunto al mio codice tra
<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>
Button:
<body>
<a id='button_down' href='#section' onclick="document.getElementById('moodvideo').pause()"><img src='scroll.png' alt='Scroll'></a>
</body>
ho controllato l'esempio è stato dato alle streghe sito e ha aggiunto che allo stesso modo per il mio html. Rif ispezionato link: https://css-tricks.com/examples/SmoothPageScroll/ ma non posso farlo funzionare ..
Inoltre, ho un altro script, strega ha bisogno della stessa azione, dopo la fine di un video. script per che ora è:
<script>
function videoEnded() {
window.location.href="#section";
}
</script>
Questo ha a che fare la stessa cosa; scorrere bene.
Spero di averlo spiegato in modo comprensibile, in caso contrario, mi piacerebbe provare di nuovo. Saluti
EDIT sceneggiatura isnt aggiunto al sito on-line perché lo script isnt lavorando ancora, se lo renderebbe easer potrei aggiungere online.
aggiornamento sito è online con gli script non lavorano