Detecting a scrollbar's position

Discussion in 'JavaScript' started by memerson, Aug 16, 2007.

  1. #1
    Hi,

    I am putting together a scrolling div of thumbnails, but I want it, when it reaches the end of the div, to jump back to the beginning if the user tries to scroll any further.

    I used a function to detect the scroll position:

    which is saying if the scrollbar reaches position 45 (the furthest right in my test div) it should jump back to 0. But, although the alert states this, it does not move the scrollbar. I'm probably using the wrong syntax or something...can anyone help?
     
    memerson, Aug 16, 2007 IP
  2. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #2
    window.scrollTo(0,0);
    Code (markup):
    You're setting the position of the entire document, not the <div>
     
    krt, Aug 16, 2007 IP