function pageScroll() { window.scrollBy(0,50);
To automatically scroll when the page loads, add the following code to the body tag:
<body onLoad="pageScroll()">
The link is similar:
<a href="javascript:pageScroll()">Scroll Page</a>
Scroll straight to a specific point:
Use the scroll () method to jump to a specific point on the page. Position position is set as pixels.
function jumpScroll() { window.scroll(0,150);
The link is similar:
<a href="javascript:jumpScroll()">Jump to another place on the page</a>
To go to the next page:
function jumpScroll() { window.scroll(0,150);
To go to a specific page:
you can name different functions in each link, for example:
<a href="javascript:jumpScroll1()">jump to page1</a> <a href="javascript:jumpScroll2()">Jump to page2</a> <a href="javascript:jumpScroll3()">Jump to page3</a>
script:
function jumpScroll1() { window.scroll(0,150); // horizontal and vertical scroll targets window.location.replace("http://page1.html"); } function jumpScroll2() { window.scroll(0,250); // horizontal and vertical scroll targets window.location.replace("http://page2.html"); } function jumpScroll3() { window.scroll(0,350); // horizontal and vertical scroll targets window.location.replace("http://page3.html"); }
This works great for me.
Link Link: http://www.mediacollege.com/internet/javascript/page/scroll.html
source share