Return to Previous Position

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • BrassWorld

    Return to Previous Position

    Howdy,

    I know how to tell a DIV with a vertical scroll bar how far to scroll:

    document.getEle mentById( 'myDIV' ).scrollTop += 40;


    However, under certain conditions, 'myDIV' is hidden. Upon once again being
    visible, I need to return (scroll) to the same position where the user was
    before 'myDIV' was hidden. However, I can't figure out how to store the current
    position for later retrieval. I've tried using the following:

    thePosition = document.getEle mentById( 'myDIV' ).scrollTop;

    But, scrollTop always seems to want to store this value instead:

    thePosition = document.body.s crollTop;

    Since the main window doesn't have a scroll bar on my screen, scrollTop always
    has a value of 0. How do I find the scrolled position of the 'myDIV' instead of
    the scrolled position of the body? Since I can set that value, I'm wondering
    why I can't retrieve it.

    Thanks!
    Jim
  • Evertjan.

    #2
    Re: Return to Previous Position

    BrassWorld wrote on 25 apr 2004 in comp.lang.javas cript:[color=blue]
    > Since the main window doesn't have a scroll bar on my screen,
    > scrollTop always has a value of 0. How do I find the scrolled position
    > of the 'myDIV' instead of the scrolled position of the body? Since I
    > can set that value, I'm wondering why I can't retrieve it.
    >[/color]

    <http://www.webreferenc e.com/js/tips/991203.html>

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)

    Comment

    • BrassWorld

      #3
      Re: Return to Previous Position

      << <http://www.webreferenc e.com/js/tips/991203.html> >><BR><BR>
      Unfortunately, that page only has information capturing a "window's"
      scrollbars. Remember, my browser's window won't have (or need) any scrollbars.
      I need information about determining a DIV's scrollbar. The fixed size of this
      DIV is smaller than most screen sizes. However, the content inside of that DIV
      is scrollable. Once again, my browser window itself will not scroll.

      I've already spent a good deal of time on Google trying to find an answer to
      this. Since I haven't be able to find an answer to my problem, maybe a good
      solution doesn't exist.

      Thanks, anyway.
      Jim

      Comment

      • Evertjan.

        #4
        Re: Return to Previous Position

        BrassWorld wrote on 25 apr 2004 in comp.lang.javas cript:
        [color=blue]
        > << <http://www.webreferenc e.com/js/tips/991203.html> >><BR><BR>
        > Unfortunately, that page only has information capturing a "window's"
        > scrollbars.[/color]

        You miss the point:

        x = document.body.s crollTop

        can be changed to

        x = document.getEle mentById("myDiv Id").scrollTo p

        To the NS version I cannot help you.


        --
        Evertjan.
        The Netherlands.
        (Please change the x'es to dots in my emailaddress)

        Comment

        • BrassWorld

          #5
          Re: Return to Previous Position

          << You miss the point:

          x = document.body.s crollTop

          can be changed to

          x = document.getEle mentById("myDiv Id").scrollTo p

          To the NS version I cannot help you. >><BR><BR>
          That is exactly how I had it written on my first post. [Actually, thePosition =
          document.getEle mentById( 'myDIV' ).scrollTop;] Thanks for confirming that the
          initial way I was doing this actually was the correct way. I needed to be
          reminded that different browsers do not always respond to a given situation in
          the same way.

          I was testing my code in Safari on the Mac. It does function (but not real
          accurately) with Mozilla on the Mac, but not in Safari. It does, however,
          function properly in IE on the Mac. I test with Windows browsers shortly.

          Jim

          Comment

          Working...