...

View Full Version : onMouseMove



JAVAEOC
01-15-2004, 12:48 AM
why doesnt this work in NS?

<script>

function followmouse(){

document.getElementById('Trail').style.top = e.pageY
document.getElementById('Trail').style.left = e.pageX
}

document.onmousemove=followmouse
</script>
<style>
.Trail{
position: absolute;
top:0;
left: 0;
}
</style>

<body>
<img src="Image.gif" id="Trail" class="Trail">

DsgnrsTLZAdmin
01-15-2004, 02:00 AM
onmousemove? followmouse function? never seen that used before, that code seems serously wrong somehow but if it works in other browsers beside netscape then try this...



<head>
<script>

function followmouse()
{
document.getElementById('Trail').style.top = e.pageY
document.getElementById('Trail').style.left = e.pageX
}
document.onMouseMove="followmouse"
</script>
<style type="text/css">
.Trail{ position: absolute; top: 0; left: 0; }
</style>
</head>
<body>
<img src="Image.gif" id="Trail" class="Trail">

nolachrymose
01-15-2004, 02:21 AM
function followmouse(evt) {
var n = document.getElementById('Trail');
n.style.left = evt.pageX;
n.style.top = evt.pageY;
}
document.onmousedown = followmouse;

Hope that helps!

Happy coding! :)

Vladdy
01-15-2004, 02:28 AM
Actually, the reason it does not work has nothing to do with capitalization. All lower case is right.
The reason it does not work in NS is that in IE the event object is global and therefore can be accessed from any function as you are doing. In Gecko, which follows the DOM2 Events, the event object is created for every event:

document.onmousemove = function(e)
{ window.status = 'Mouse position: ' + e.pageX + ' : ' + e.pageY;
}



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum