Click to See Complete Forum and Search --> : JavaScript and Netscape Nav. - Why can't I capure the document.onmousemove event?
gangelo
June 23rd, 2002, 11:30 AM
All I want to do is capture the document.onmousemove event - for some reason it is not working - any suggestions? It works fine in IE.
In my <body>:
<script language="JavaScript">
document.onmousemove = f_imgBlinkEyes;
</script>
In my .js:
function f_imgBlinkEyes()
{
/* never gets here */
...some stuff
}
Zvona
June 24th, 2002, 05:52 AM
<!-- Example Written by Zvona -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>Mouse handling</title>
<meta http-equiv="content-type" content="text/html;charset=iso-8859-1;" />
<script type="text/javascript">
oParent = (document.all)?document.documentElement:window;
oParent.captureEvents(Event.MOUSEMOVE);
oParent.onmousemove = zMove;
function zMove(e)
{
mouseX = (document.all)?window.event.x:e.pageX;
mouseY = (document.all)?window.event.y:e.pageY;
window.status = mouseX +" : "+ mouseY;
}
</script>
</head>
<body>
<h2>Example of mouse handling for IE and NS(both Mozilla/Navigator)</h2>
</body>
</html>
spufi
June 28th, 2002, 02:56 PM
Do you get any error messages? I would look into setting up your JavaScript console, or a pop up window so you can debug your code. Anyway, it's a pretty easy fix since you are calling the function f_imgBlinkEyes while you have it written as a variable name. Try this...
document.onmousemove = f_imgBlinkEyes();
coolbiz
June 28th, 2002, 03:41 PM
Originally posted by spufi
Do you get any error messages? I would look into setting up your JavaScript console, or a pop up window so you can debug your code. Anyway, it's a pretty easy fix since you are calling the function f_imgBlinkEyes while you have it written as a variable name. Try this...
document.onmousemove = f_imgBlinkEyes();
Actually, it should be without the "()" since you're assigning the reference to the function and not executing the function.
Trapping mouseevent is really tricky on Netscape version below 6.x. Also not on Event-Bubling, which means if you have an image on your page and your mouse is over that image, the event might not get fired up properly.
Post the URL to the page and I can try to take a look at it.
-Cool Bizs
codeguru.com
Copyright 2007 Jupitermedia Corporation All Rights Reserved.