Body onscroll, scrollTop, scrollLeft not working with master pages ???

G

gregtyndall

I have a weird problem. I'm using a master page to hold a menu that I
want to scroll as the user scrolls in the browser window so it will
always be visible. First off, putting onsroll in the body tag of my
master page does nothing. Oh, IE is the browser.

<body onscroll="alert('scrolling')">

I was able to get around this setting an event hander for
window.onscroll. However, body.scrollTop is always 0! I wrote a plain
aspx test file to make sure I wasn't losing my mind and it worked
perfectly. Here is the code for the test file...
.....
<script language="javascript">
function movediv()
{
//document.all.div1.style.top=document.body.scrollTop;
alert(document.body.scrollTop);
}

</script>
</HEAD>

<body onscroll="movediv()">
<form id="Form1" method="post" runat="server">
<div id="div1" style="position:absolute">This is a div</div>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/>
<br /><br /><br /><br /><br /><br /><br /><br /><br /><br /><br
/>
</form>
</body>
</HTML>

In my .master page I'm basically doing this

.....
<body>
<table>
<tr>
<td>
<div id="divMenu" style="position:absolute">menu buttons
here</div>
</td>
<td>
<asp:contentplaceholder ....
</td>
</tr>
</table>

<script language=javascript>
window.onscroll=scrolldiv;

function scrolldiv()
{
document.all.divMenu.style.top=document.body.scrollTop;
}

</script>

body.scrollTop is always 0!!! I checked scrollLeft and it is always 0
as well! I also tried adding a button that just alerts the scrolltop
value which is also 0. And yes, I the page was scrolled down so 0 is
an invalid value.

I've been searching for an answer to this for hours and have found
nothing. Does anyone have a clue?

TIA,
Greg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,262
Messages
2,571,052
Members
48,769
Latest member
Clifft

Latest Threads

Top