473,395 Members | 1,996 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,395 software developers and data experts.

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

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 <--
doctype ... statement near the top of the master page.
Somehow this forces some w3c standard where scrolltop isn't supported.
I removed the doctype declaration from my masterpage and everything
works fine.
Actually I changed the dtd type to something else less strict - don't
have the code in front of me.

From: gregtynd...@gmail.com - view profile
Date: Thurs, Dec 29 2005 11:39 am
Email: gregtynd...@gmail.com
Groups: microsoft.public.dotnet.framework.aspnet
Not yet rated
Rating:
show options
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse | Find messages by this author

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

Nov 25 '06 #1
0 2627

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

Similar topics

3
by: Need_help | last post by:
Sorry for inconveniance, but I couldn't check the newsgroup since friday. I can't see any solutions right now on my post... So, one more time... (if anyone noticed the solution)... I have...
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...
1
by: sri_san | last post by:
Hello, I looked at alternatives to SmartNavigation and found the code listed here. I am not able to get the code working on pages which has a datagrid with EditCommandColumn(edit/update are image...
0
by: gregtyndall | last post by:
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...
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...
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
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.