Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How can I capture MOUSE MOVE and call a function?

 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
For example, if my mouse is moved on screen, a function will be called, if it stop, nothing will be done. I've a simple script as follows:
<heaD>
<script>
function Key_Up(e) {
alert("message");
}
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = Key_Up;
</script>
</head>
<body>1</body>

However, it doesn't do what i suppose i want to do, if my mouse move, the alert message will LOOP forever, but my basic idea is when my mouse move, alert appear, press OK using keyboard, alert message disappear (<---but now the alert appear again). Please would anyone suggest a solution?Thanks
 
Ken Shamrock
Ranch Hand
Posts: 139
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forget to say that my script aims on running at Netscape 4.xx, not works for IE
 
Yuriy Fuksenko
Ranch Hand
Posts: 413
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You should have a flag on yout page - if mouse move, and flag is set, than show dialog( alert).
If user hit OK on alert - reset a flag, so alert will not appear.
You might need to replace standart alert function with some thing else - either layer or another browser window (by the way, showModalDialog from for IE is exactly what you need).
By the way, for IE you need not to call captureEvent function, so put
if (!document.all) window.captureEvent(...)
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic