J
JezB
I have some javascript to restore the scroll position of a DIV over
postbacks. I've tested it on all major browsers and the only one it doesn't
work on is Opera. Could someone tell me why, and what I can do to (a) test
that it's Opera that's running and (b) how to get and set the scroll
position - scrollTop does not seem to work.
Here's the code :
// scrolls the "what" element given to it (the DIV scroll area)
// call from body onload (ie. on every postback)
function ScrollIt(what){
document.getElementById(what).scrollTop =
document.Form1.ScrollPos.value;
}
// saves the DIV scroll position (call from onscroll on the DIV)
function setdiv(val) {
document.Form1.ScrollPos.value = val.scrollTop;
}
I save the scroll position in a hidden field "ScrollPos" :
<input id="ScrollPos" type="hidden" value="0" name="ScrollPos"
runat="server">
postbacks. I've tested it on all major browsers and the only one it doesn't
work on is Opera. Could someone tell me why, and what I can do to (a) test
that it's Opera that's running and (b) how to get and set the scroll
position - scrollTop does not seem to work.
Here's the code :
// scrolls the "what" element given to it (the DIV scroll area)
// call from body onload (ie. on every postback)
function ScrollIt(what){
document.getElementById(what).scrollTop =
document.Form1.ScrollPos.value;
}
// saves the DIV scroll position (call from onscroll on the DIV)
function setdiv(val) {
document.Form1.ScrollPos.value = val.scrollTop;
}
I save the scroll position in a hidden field "ScrollPos" :
<input id="ScrollPos" type="hidden" value="0" name="ScrollPos"
runat="server">