How do I get the mouse coords?
I tried "window.event.clientX" and "window.event.clientY" - itworks on IE6 but it won't work on FireFox.
Get mouse coordinates
Moderator: General Moderators
Not tested but something like this has a workaround.
Code: Select all
function foo(e)
{
if (window.Event)
{
x = e.screenX;
y = e.screenY;
}
else
{
x = window.event.clientX;
y = window.event.clientY;
}
}This works in both IE 6.0 and FF 1.0.7
Code: Select all
<html>
<head>
<script type="text/javascript">
function foo1(scrObj, e)
{
e = e || window.event;
var id1 = document.getElementById("id1");
var x = e.screenX || e.clientX;
var y = e.screenY || e.clientY;
id1.innerHTML = x + ", " + y;
}
</script>
</head>
<body>
<div id="id1" style="border:1px solid black;width:250px;height:250px" onmousemove="foo1(this, event)">
Test Contents
</div>
</body>
</html>