moving layer (js) problem when inserted to ASPX page

lamy

Regular
Joined
Dec 12, 2005
Messages
56
Location
under your bed
i have a floating DIV tag which moves along with the page, already tested it on modern browsers (with .HTM as extension, tested with IE6, NS8, Opera 8, Firefox 1.5 and Safari 1.x), it was working but it doesnt when i inserted the same code in my ASPX page.

heres the same html page im using
Code:
<html>
<script language="javascript">
function moveDIV(source)
	{
	var frame = document.getElementById("floatingDIV");
	var offset = 0;

	// IE compatible
	if ((document.all?true:false) == true) 
		offset = source.scrollTop; 
	else 
		offset = document.body.scrollTop;

	frame.style.top = offset;
	}
</script>
<body OnMouseMove="moveDIV(this)">
<div id="floatingDIV" style="position:absolute">
This is the floating DIV
</div>
<p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p>
<p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p>
</body>
</html>

there seems to be a problem with document.getElementById but it is client-side, it shouldnt affect my ASP.Net page or theres something that i should be doing to make it work, anyone?
 
What does the markup for the aspx page look like?

Also

if((document.all?true:false)==true)
{}
else
{}

is the same as:

if(document.all)
{}
else
{}
 
the ASPX page is almost the same except for the head part

Code:
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="WebForm1.aspx.vb" Inherits="WebForm1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>WebForm1</title>
</head>

<script language="javascript">
function moveDIV(source)
	{
	var frame = document.getElementById("floatingDIV");
	var offset = 0;

	// IE compatible
	if ((document.all?true:false) == true) 
		offset = source.scrollTop; 
	else 
		offset = document.body.scrollTop;

	frame.style.top = offset;
	}
</script>
<body OnMouseMove="moveDIV(this)">
<div id="floatingDIV" style="position:absolute">
This is the floating DIV
</div>
<p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p>
<p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p><p>-</p>
</body>
</html>
 
saw the problem, its in DOCTYPE tag, i guess id have to find a way to make it compatible, as a work around, i removed the DOCTYPE tag.
 
Last edited:
Just change your DOCTYPE tage to the following:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
 
Back
Top