Connecting Tech Pros Worldwide Help | Site Map

Problem programatically setting scrollbar position in IE

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 23rd, 2005, 07:06 PM
alvinpoon@gmail.com
Guest
 
Posts: n/a
Default 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.


  #2  
Old July 23rd, 2005, 07:06 PM
RobB
Guest
 
Posts: n/a
Default Re: Problem programatically setting scrollbar position in IE

alvinp...@gmail.com wrote:[color=blue]
> 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[/color]
left[color=blue]
> 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[/color]
area.[color=blue]
>
>
> 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[/color]
but[color=blue]
> not in Internet Explorer? Is there any way to fix the code so that[/color]
it[color=blue]
> will work in Internet Explorer and Netscape?
>
> Thank you for your help.[/color]

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. #;-)

 

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.