Scroll top of page
Explanation
The following Java Script will show you how to make the return to top of page with a slight slow down as it reaches the top of page. You may have noticed this on our web site, and it is the program we use when you click on ![]()
Chapter Navigation:
Note:
JavaScript Code
var delay=0; var pix=0; var pixmax=0; var inc=0;
function MyNavigator() {
if (navigator.appName=="Microsoft Internet Explorer") {
pixscroll = document.documentElement.scrollTop;
}
else {
pixscroll = window.pageYOffset;
}
}
function ScrollUpToPage() {
delai=1;
inc=-20;
MyNavigator()
pix = pixscroll;
if (-inc > pixscroll) {
if (pixscroll > 15) {inc = -pixmax+15;};
}
if (pixscroll > 15) {self.scrollTo(0,15);pixscroll=15;pix=15;inc=-5;}
setTimeout("scroll()",delay);
}
function scroll() {
pix=pix+inc;
self.scrollBy(0,inc);
if (pix >= 0) {
setTimeout("scroll()",delay);
MyNavigator();
if (pixscroll <= 5) {inc=-1;}
if (pixscroll > 5) {if (pixscroll <= 10) {inc=-3;};}
if (pix < pixscroll) {pix=0;};
}
}
Script placement
Select the javascript functions and place them between
and
.
At the link level, name the function ScrollUpToPage() for instance.
Example:
onClick="ScrollUpToPage()";>![]()