Josh, Hope this time is in better formatting. If I used onload="javascript:Scroll();" to the tab and I clicked a control that is set to Auto Postback, the page was reload and Scroll() function was called. The GetCoords() never be called. I added alert in the
Scroll() function and it came up blank every time. If I removed onload="javascript:Scroll();", the GetCoords() function was called every minute. The scrollX and scollY were correct if the control is not set to AutoPostback and return zeros if the control is
set to AutoPostback. The DataGrid control does not have AutoPostback property. The Sort Expression is set in the Property Builder. It may work differently from the AutoPostback property. Here is my code: <script language="javascript"> function GetCoords()
{ var scrollX, scrollY; if (document.all) { if (!document.documentElement.scrollLeft) scrollX = document.body.scrollLeft; else scrollX = document.documentElement.scrollLeft; if (!document.documentElement.scrollTop) scrollY = document.body.scrollTop; else scrollY
= document.documentElement.scrollTop; } else { scrollX = window.pageXOffset; scrollY = window.pageYOffset; } document.forms[0].scrollLeft.value = scrollX; document.forms[0].scrollTop.value = scrollY; //alert(scrollX); //alert(scrollY); } function Scroll()
{ var x = document.forms[0].scrollLeft.value; var y = document.forms[0].scrollTop.value; window.scrollTo(x, y); alert(x); alert(y); } window.setInterval('GetCoords()', 1000); </script> <form id="Form1" method="post" runat="server"> <input id="scrollLeft" type="hidden">
<input id="scrollTop" type="hidden"> Thanks. DanYeung
danyeung
Participant
754 Points
369 Posts
Re: Using javascript to maintain the scroll position.
Mar 20, 2007 04:04 AM|LINK