...

View Full Version : Resolved Scroll Position, Start and Restart



exocintact
07-28-2009, 09:31 PM
Hi everyone,

I'm using an autoscroll feature on my webpage using javascript

and also implementing a reset button to bring the scroll to the very top

but the two are not being compatible.. the reset button DOES scroll to the top but when I click the start button again after its been reset it starts scrolling from where it last left off (and not back from the top).

Here's the code:


function back_to_top(id){
document.getElementById(id).scrollTop=0
}
i = 0

function scroll() {
i = i + speed


and the buttons:


<input onclick="scroll()" type="button" value="Start">
<input onclick="clearTimeout(t1)" type="button" value="Stop">
<br><input onclick="back_to_top('transcript')" type="button" value="Reset">

This is my final task for this site and this "glitch" is starting to get very frustrating. Any help would be greatly appreciated!

ckeyrouz
07-28-2009, 09:34 PM
change your back_to_top function from thisL

function back_to_top(id){
document.getElementById(id).scrollTop=0
}


to this

function back_to_top(id){
document.getElementById(id).scrollTop=0;
i=0;
}

And may I suggest that it is better to end your lines and/or commands with ";" (semi-columns)

exocintact
07-28-2009, 09:41 PM
wow, I can't believe how helpful (and fast!) you guys have been here.

big thanks ckeyrouz, it worked perfectly.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum