Martin wrote:
I have a web page (IE only; intranet only) that is both wider and
longer than the browser window. I've noticed that if the user has
scrolled the page DOWN and then refreshes the page, the new page
automatically scrolls down to same position. However, this automatic
scrolling does NOT happen if the user has scrolled over towards the
right side.
FWIW, I'm trying to come up with a script that will pass the
.scrollTop and .scrollLeft properties back to the server on a refresh
(and then use .scrollTo to position the new page) but I'm hoping there
might be a simpler way.
Since the full process is initiated by javascript, you should rather use
client-side ways of state keeping, for instance cookies or frames - you
could also consider IE behaviors (.htc files).
There's also the following old IE thing (navigator expando), which runs
happily in my current IE; that's probably more a hack than anything, but
since it's been here for years it might as well be used, for instance as
a js include - to be tested accordingly though, I seem to remember it
crashing upon browser closing, but cannot remember the specifics of the
test I tried then (long ago!).
<script type="text/javascript">
if(window.attachEvent) {
window.attachEvent(
"onbeforeunload",
function() {
navigator.scrollLeft=(
document.compatMode &&
document.compatMode.indexOf("CSS")!=-1 &&
document.documentElement || document.body
).scrollLeft;
}
);
window.attachEvent(
"onload",
function() {
if (typeof navigator.scrollLeft!="undefined")
scrollBy(navigator.scrollLeft);
}
);
}
//test
for(var ii=0,s="";ii++<100||document.write(s);s+=ii);
</script>
HTH
Yep.