Entry
How can I retain the vertical scroll position of a textarea after changing its contents?
Jan 13th, 2005 16:04
Reha Sterbin, Phil Endecott, http://faqts.com/knowledge_base/view.phtml/aid/7746/fid/130
(Tested in Netscape7.2, IE6, and Firefox1/Mozilla5)
function changeAndSetScroll(box){
scrollPos = box.scrollTop;
//
// make your changes to the textarea here
//
box.scrollTop = scrollPos;
}
<textarea name="maintext"></textarea>
<input type="button" value="Change and Set Scroll"
onClick="changeAndSetScroll(document.getElementById('maintext'));">