Reputation: 339
How do I make a automatic scroll when people go on a page?
Here's my current code.
function jumpScroll() {
window.scroll(0,150); // horizontal and vertical scroll targets
}
Upvotes: -1
Views: 155
Reputation: 3089
Hi Please Try the Below Code:
function jumpScroll() {
window.scrollBy(0,150); // horizontal and vertical scroll increments
scrolldelay = setTimeout('jumpScroll()',100); // scrolls every 100 milliseconds
}
To being scrolling automatically when the page loads, add the following code to the body tag:
<body onLoad="jumpScroll()">
To begin scrolling when prompted by the user, call the function from a link or button:
<a href="javascript:jumpScroll()">Scroll Page</a>
Button:
<input type="button" onClick="jumpScroll()" value="Scroll Page">
Comple Source: Automatic Scroll
Hope this helps.
Upvotes: 0
Reputation: 328
Change scroll to scrollBy
Make sure and add
onLoad="jumpScroll()"
to your body tags.
Upvotes: 2