Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > SOLUTION: Body onscroll, scrollTop, scrollLeft not working with master pages ???

Reply
Thread Tools

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

 
 
bluegrasslover@gmail.com
Guest
Posts: n/a
 
      11-25-2006
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: (E-Mail Removed) - view profile
Date: Thurs, Dec 29 2005 11:39 am
Email: (E-Mail Removed)
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

 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SOLUTION: Body onscroll, scrollTop, scrollLeft not working with master pages ??? bluegrasslover@gmail.com ASP .Net 0 11-25-2006 01:59 AM
Browsers not supporting document.documentElement.scrollLeft? petermichaux@gmail.com Javascript 2 09-03-2006 08:45 PM
Cross Page Post Back When Using Mixture of Master Pages and Non-Master Pages Jason@webbit.com ASP .Net 1 05-16-2006 02:00 PM
Body onscroll, scrollTop, scrollLeft not working with master pages ??? gregtyndall@gmail.com ASP .Net 0 12-29-2005 04:39 PM
Not detecting body.scrollTop and body.scrollLeft in IE6 London Boy Javascript 2 01-12-2004 08:44 AM



Advertisments