Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Scroll Question

Status
Not open for further replies.

jaschulz

Programmer
May 20, 2005
89
FR
I have a div with a fixed height and overflow: auto. I set the content of this div via a (prototype) ajax call. Sometimes the content is long enough to force a vertical scroll bar, sometimes it isn't. If I load content A, and it is long enough to force the scroll bar, and then I use the scroll bar to move down, and then I load Content B (which is also long enough to force a scroll bar), the previous scroll position is maintained with the new content.

How can I force the scrollbar to return to the top with each new content?

Thanks,

JAS
 
Turns out what I needed was:

document.getElementById('myDiv').scrollTop = 0;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top