Page automatically scrolls back up...

Discussion in 'HTML & Website Design' started by bobisawsome7, Aug 8, 2006.

  1. #1
    <script language="JavaScript1.2">               
                   
    //change 1 to another integer to alter the scroll speed. Greater is faster               
    var speed=1               
    var currentpos=0,alt=1,curpos1=0,curpos2=-1               
    function initialize(){               
    startit()               
    }               
    function scrollwindow(){               
    if (document.all)               
    temp=document.body.scrollTop               
    else               
    temp=window.pageYOffset               
    if (alt==0)               
    alt=1               
    else               
    alt=0               
    if (alt==0)               
    curpos1=temp               
    else               
    curpos2=temp               
    if (curpos1!=curpos2){               
    if (document.all)               
    currentpos=document.body.scrollTop+speed               
    else               
    currentpos=window.pageYOffset+speed               
    window.scroll(0,currentpos)               
    }               
    else{               
    currentpos=30               
    window.scroll(0,currentpos)               
    }               
    }               
    function startit(){               
    setInterval("scrollwindow()",30)               
    }               
    window.onload=initialize               
    </script>
    HTML:
    That code makes a page scroll from top to bottom,

    How can I get this code (or get a code) to scroll backup when a user scrolls down?


    Thanks,

    Anmar
     
    bobisawsome7, Aug 8, 2006 IP
  2. Daniel

    Daniel Peon

    Messages:
    1,453
    Likes Received:
    70
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Just a guess but did you try changing the values around in line 5 ?

    curpos1=0,curpos2=-1

    change to

    curpos1=-1,curpos2=0

    ?
     
    Daniel, Aug 10, 2006 IP
    Addurobi likes this.
  3. bobisawsome7

    bobisawsome7 Notable Member

    Messages:
    1,466
    Likes Received:
    104
    Best Answers:
    0
    Trophy Points:
    200
    #3
    Hey Daniel,

    I already got it fixed by changing the speed to negative ;)

    Thanks anyway.
     
    bobisawsome7, Aug 10, 2006 IP
    Daniel likes this.
  4. Daniel

    Daniel Peon

    Messages:
    1,453
    Likes Received:
    70
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Oh ok :p Thanks :)
     
    Daniel, Aug 10, 2006 IP