// function saves scroll position
function fScroll(val)
{
var hidScroll = document.getElementById('hidScroll');
hidScroll.value = val.scrollTop;
}
// function moves scroll position to saved value
function fScrollMove(what)
{
var hidScroll = document.getElementById('hidScroll');
document.getElementById(what).scrollTop = hidScroll.value;
}
</script>
</head>
<body onload="fScrollMove('div_scroll');" onunload="document.forms(0).submit()";>
<form>
<input type="text" id="hidScroll" name="a">< /br>
<div id="div_scroll" onscroll="fScroll(this);"
style="overflow:auto;height:100px;width:100px;">
.. VERY LONG TEXT GOES HERE
</div>
</form>
</body>
</html>
1条答案
按热度按时间sr4lhrrt1#
您是否在该特定页面中使用UpdatePanels?
如果是,以下文章可能会给予您一些指导:
http://basgun.wordpress.com/2008/06/09/maintain-scroll-position-updatepanel-postback/
如果为否,则此选项可能有助于:
Javascript: Maintaining Page Scroll Position
下面是这篇文章的代码:
希望这些链接之一的帮助!