stava in un file esterno js
codice:
var TimerOfScrollPage;
function JumpToPageTop() {
ScrollPage(0, 0, 10);
}
function ScrollPage(toX, toY, breaking) {
if (TimerOfScrollPage) {
clearTimeout(TimerOfScrollPage);
}
if (!toX || toX < 0) {
toX = 0;
}
if (!toY || toY < 0) {
toY = 0;
}
if (!currX) {
currX = CurrLeft();
}
if (!currY) {
currY = CurrTop();
}
if (!breaking) {
breaking = 5;
}
currX += (toX - CurrLeft()) / breaking;
if (currX < 0) {
currX = 0;
}
currY += (toY - CurrTop()) / breaking;
if (currY < 0) {
currY = 0;
}
currX = Math.floor(currX);
currY = Math.floor(currY);
window.scrollTo(currX, currY);
if (currX != toX || currY != toY) {
TimerOfScrollPage = setTimeout("ScrollPage(" + toX + "," + toY + "," + breaking + ")", unittime);
}
}