Jump to content
Xtreme .Net Talk

moving layer (js) problem when inserted to ASPX page


Recommended Posts

Posted

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

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

slow down when you need to hurry, stop when you need to move on,

look back when you need to forget, or you might slip and leave sanity

Posted

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

{}

Posted

the ASPX page is almost the same except for the head part

 

<%@ 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>

slow down when you need to hurry, stop when you need to move on,

look back when you need to forget, or you might slip and leave sanity

Posted (edited)
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. Edited by lamy

slow down when you need to hurry, stop when you need to move on,

look back when you need to forget, or you might slip and leave sanity

Posted
tnx bri189a

slow down when you need to hurry, stop when you need to move on,

look back when you need to forget, or you might slip and leave sanity

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...