473,387 Members | 1,899 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Auto scroll to correct position?

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.

Is there a setting that needs to be adjusted to get this to happen? Or
something I need to do in the page?

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.

Any suggestions?

Thanks.
Jul 23 '05 #1
1 2013
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.
Jul 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: PhilC | last post by:
Hi Folks, I'm trying to click on a canvas to draw a line. The canvas has scroll bars. All is well until I move the scrollbars. This naturally because the relationship between my screen click and...
1
by: Glabbeek | last post by:
I'm changing the layout of my site. Instead of using tables, I will use DIVs. It's working fine, except for 1 thing: In IE6 some DIVs are not the correct width. Mozilla and Opera are showing the...
5
by: Duane Lambe | last post by:
Hi - just a quick question, I hope it's simple enough that a visual example isn't required. I have an internal site, everything's the way I want it, but there's an anomoly in both Opera and...
2
by: lawrence | last post by:
I thought I was fighting a PHP problem, so I asked about this on a PHP list, but they felt it was a Javascript problem, so I'm reposting a bit of the debate here. Could this Javascript, below,...
6
by: Rachel Suddeth | last post by:
I have the index of a line in the Lines array of a RichTextBox. I would like to have it scroll so that line displays at the top. Is there no way to do this? The only way I can see to make it...
0
by: 23s | last post by:
Is there any way I can send a vertical value to a form's scroll position? I have a full-screen form that, at launch, contains an empty tab sheet. At run time, the user can dynamically append a...
1
by: pravinnweb | last post by:
can anyone tell me how to set auto height to outer div that is in green box id "gray-background" it should increase relatively to inner div "smbox" here is the css and html code it should work in...
15
dlite922
by: dlite922 | last post by:
I'm back again, Intro: I've got a floating div (outerDIV) with fixed width that contains an image (IMG) and a div that contains a short text (innerDIV) Problem: In FF, the innerDIV is...
12
Frinavale
by: Frinavale | last post by:
I think I'm trying to do something impossible. I have a <div> element with a overflow style set to "scroll". In other words my <div> element allows the user to scroll the content within it. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.