LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-26-2007, 01:42 PM   #1
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Setting scroll position in Internet Explorer


What I feared had happened. I developed a web page amd tested it in Opera, and it doesn't work in IE6.

This is the code snippet:

Code:
<script type="text/javascript">
  scrollTo(0,344);
  alert ('current position after scroll: ' + document.body.scrollTop);
</script>
Now obviously the page does NOT scroll to y position 344. In the last line, the alert shows the current and correct scroll position.

In other words, retrieving the scroll position works fine, but setting of the scroll position does not.

Alternatively I tried this code:

Code:
<script type="text/javascript">
  document.body.scrollTop = 344;
  alert ('current position after scroll: ' + document.body.scrollTop);
</script>
But that didn't work either.

As a matter of fact, there seems to be no relationship between what I put the scroll position to, and the real position after the call.

These are a number of requested positions, and the real position the scroll position moves to:

Code:
requested   actual
230          203
324          135
523           94
Now I don't see any logic here.

In Opera it works perfectly. In Firefox it does not, but that is due to a (documented) different way of specifying the scroll position.

If anyone ever succesfully scrolled the window in IE to a predetermined position, please let me know!

jlinkels
 
Old 02-26-2007, 06:57 PM   #2
Cliffster
LQ Newbie
 
Registered: Feb 2007
Posts: 26

Rep: Reputation: 15
Not exactly an answer to that, but...

I'd try and have it jump to a named anchor in the page, which is more or less the same result.
 
Old 02-27-2007, 05:07 AM   #3
jlinkels
LQ Guru
 
Registered: Oct 2003
Location: Bonaire, Leeuwarden
Distribution: Debian /Jessie/Stretch/Sid, Linux Mint DE
Posts: 5,195

Original Poster
Rep: Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043Reputation: 1043
Yes, I know that technique as well.

I am afraid it is not fine grained enough. The application is running on an intranet, with a dozen or more controls. Whenever a control is changed, the contents is written to MySQL, and the page is refreshed.

Since this process is fast, it should look like the page is remaining in place. That is hardly possible with bookmarks. I agree that the user sees the page again in more or less the same position, and that would be satisfactory if the page is away for 2 seconds or so while refreshed.

In the mean time I have made some progress.

If I put the scrollTo(x,y) statement in the <body onload="blah blah"> tag, it works in IE as well. Not as beautiful as in Opera though, first the entire page is loaded and THEN it scroll to the desired position, which is not nice to the eye. (Think about that, it is in the onload statement...) In Opera it remain satisfactory.

Now I am beginning to understand why so often web sites don't in Opera which do in IE. It is IE not complying to the specifications forcing developer to write eeky code, not the other way around.

jlinkels
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Intellimouse Explorer side buttons and scroll wheel broken after kernel 2.6.10 Ricochet Linux - Hardware 3 07-28-2005 05:21 PM
Internet Explorer vs. Other Browsers (Internet Standards) smaida Linux - General 6 10-11-2004 04:27 AM
Internet Explorer only internet page?? jimdaworm Linux - Software 9 08-08-2004 02:26 PM
MS Explorer Mouse scroll and right click cmsustud19 Linux - Newbie 1 03-26-2004 07:18 PM
internet explorer fiburglas Linux - Networking 8 05-26-2003 12:08 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 09:56 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration