How to retain the scrollbar position?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • srinivasyadavkota
    New Member
    • Sep 2007
    • 8

    How to retain the scrollbar position?

    Hello experts here,
    plz help me,
    When I Scroll down my web page using vertical scroll bar to some point and when refreshed, I was

    unable to retain back the scrolled position, instead it always goes to the top part of the page.

    How can I retain this scrolled position even after refreshing the page ?
    a piece of code helps.
    Thanks and Regards,
    SrinivasKota.
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5388

    #2
    hi ...

    welcome to TSDN ...

    let me give you an idea for that: you need to retrieve the Y-scrollbar-position:

    NS: window.pageYOff set
    IE: document.body.s crollTop

    and on page-refresh you use (in onload of the document's body):

    [CODE=javascript]window.scrollTo (x, y);[/CODE]
    where y is your retrieved position (x might be 0). now your problem is ... how to store the retrieved position? :) ... you may use a cookie or pass it with a query string, or whatever ... so onload of the page you may ask for the y-position of the scrollbar and set it with scrollTo() ...

    kind regards

    Comment

    Working...