467,912 Members | 1,568 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,912 developers. It's quick & easy.

Problem programatically setting scrollbar position in IE

Hello,

I have a problem setting the scrollbar position of a div region on a
webpage which is posted at

http://www.geocities.com/virtuosity999/Logon.htm

If the page is loaded with Netscape, the vertical scrollbar on the left
side will be moved down a little bit but if the page is loaded with
Internet explorer, the scrollbar remains at the top of the scroll area.
The tag for the div region is:

<div id="UserList" style="border: 0px none rgb(0, 0, 0); position:
static; width: 100%; height: 180px; overflow: auto; background-color:
rgb(231, 232, 234); visibility: visible;">

The javascript I'm using to move the scrollbar down is:

document.getElementById('UserList').scrollTop=25

Can anyone tell me why the javascript code above works in Netscape but
not in Internet Explorer? Is there any way to fix the code so that it
will work in Internet Explorer and Netscape?

Thank you for your help.

Jul 23 '05 #1
  • viewed: 7113
Share:
1 Reply
alvinp...@gmail.com wrote:
Hello,

I have a problem setting the scrollbar position of a div region on a
webpage which is posted at

http://www.geocities.com/virtuosity999/Logon.htm

If the page is loaded with Netscape, the vertical scrollbar on the left side will be moved down a little bit but if the page is loaded with
Internet explorer, the scrollbar remains at the top of the scroll area.

The tag for the div region is:

<div id="UserList" style="border: 0px none rgb(0, 0, 0); position:
static; width: 100%; height: 180px; overflow: auto; background-color:
rgb(231, 232, 234); visibility: visible;">

The javascript I'm using to move the scrollbar down is:

document.getElementById('UserList').scrollTop=25

Can anyone tell me why the javascript code above works in Netscape but not in Internet Explorer? Is there any way to fix the code so that it will work in Internet Explorer and Netscape?

Thank you for your help.


Try calling it onload. IE often needs to 'set up' before it allows
scripting of elements.

Unfortunately, you'll probably notice a annoying delay before
window.onload is called - the result of a fairly horrendous amount of
code duplication. Even the example you posted above might have simply
been:

<div id="UserList"
style="border:none;height:180px;overflow:auto;back ground-color:rgb(231,
232, 234);">

....and should have been moved to a stylesheet, possibly assigned by
class to avoid duplication. Many, many more examples. Even your naming
is verbose. Slim that thing down. #;-)

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Tamir Kamara | last post: by
6 posts views Thread by Colin McGuire | last post: by
9 posts views Thread by Andy Baxter | last post: by
1 post views Thread by orofiamma | last post: by
reply views Thread by =?Utf-8?B?Q2hyaXN0aWFuIEhhdmVs?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.