473,385 Members | 1,523 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

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

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.scrollTo p;
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.scrol lTop;
}

</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

Dec 29 '05 #1
0 2715

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: viza | last post by:
Hi! I use the onscroll event to make something like the CSS position:fixed; for MSIE. In MSIE/5.5, before a function is assigned to the event handler, it has the value null. In Opera, it is...
2
by: London Boy | last post by:
Hi, i've done a script that makes a DIV appear and follow the mouse cursor and it works fine but, it has a small glitch, when i scroll the document, the DIV doesn't appear beside the cursor but...
2
by: Earl Teigrob | last post by:
I am trying to build a custom control to wrap my smart navigation implimention (not microsofts 'cause it has problems) The follow code works fine when the onclick and onload events are defined in...
5
by: sam | last post by:
Hi all, I am using documnet.body.scroll to disable the window scroll bar. This works in IE only and not other browsers. Can any one tell me if there is any such method which is cross browser...
1
by: PCK | last post by:
My goal is to populate the body element so that I can add an onkeydown event. <body onkeydown='x();'></body> I am currently using master/content pages. I do not want this function on every...
0
by: bluegrasslover | last post by:
I've gotten a couple of emails about this problem lately so I'm going to post the solution that someone emailed me a while back. When you create a master page visual studio automatically adds a...
2
by: =?Utf-8?B?SGFyZHkgV2FuZw==?= | last post by:
Hi all, I created a complex ASPX page, nested inside a master page and Ajax UpdatePanel. In one of my Javascript function I need to capture mouse position. I use alert(document.body.scrollTop) to...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.