Scrolltop and onscroll javascript for firefox

We use a javascript function to postback (asp.net) to the same position on the page. This function does not seem to work with Firefox -- i think its because onscroll is not recognized.

<BODY ID="Body" runat="server" ONSCROLL="bodyscroll()" BOTTOMMARGIN="0" LEFTMARGIN="0"
            TOPMARGIN="0" RIGHTMARGIN="0" MARGINWIDTH="0" MARGINHEIGHT="0">

<script language="JavaScript"><!--
         function bodyscroll() {
           var F=document.forms[0];
           F.ScrollTop.value=Body.scrollTop;
         }
         //--></script>

<INPUT ID="ScrollTop" runat="server" NAME="ScrollTop" TYPE="hidden">

Can someone recommend the best way to modify this script to work with firefox and safari also?

Thanks for any tips!
bda01Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ZvonkoSystems architectCommented:
Here you go:

<script language="JavaScript"><!--
         function bodyscroll() {
           document.forms[0].ScrollTop.value=document.body.scrollTop;
         }
         //--></script>


Better would be to give a name to the form and access the the form by name:
<script language="JavaScript"><!--
         function bodyscroll() {
             document.myForm.ScrollTop.value=document.body.scrollTop;
         }
         //--></script>

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
bda01Author Commented:
I don't understand how this would help... I was under the impression that the OnScroll in the form tag was what was causing issues...

Thanks for the reply!
0
ZvonkoSystems architectCommented:
The problem was that your function did not reference the document.body correctly for Netscape.
Your syntax works only in IE.
0
ZvonkoSystems architectCommented:
Does it now work for you with my script version?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.