Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Scroll Position, Start and Restart

    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:
    Code:
    function back_to_top(id){
    document.getElementById(id).scrollTop=0
    }
    i = 0
    
    function scroll() {
    i = i + speed
    and the buttons:
    Code:
    <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!
    Last edited by exocintact; 07-28-2009 at 10:41 PM.

  • #2
    Senior Coder ckeyrouz's Avatar
    Join Date
    Jun 2009
    Location
    Montreal, Canada
    Posts
    1,044
    Thanks
    5
    Thanked 179 Times in 179 Posts
    change your back_to_top function from thisL
    Code:
    function back_to_top(id){
    document.getElementById(id).scrollTop=0
    }
    to this
    Code:
    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)

  • Users who have thanked ckeyrouz for this post:

    exocintact (07-28-2009)

  • #3
    New to the CF scene
    Join Date
    Jul 2009
    Posts
    4
    Thanks
    2
    Thanked 0 Times in 0 Posts
    wow, I can't believe how helpful (and fast!) you guys have been here.

    big thanks ckeyrouz, it worked perfectly.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •