DelphiFAQ Home Search:

Catch mouse move events in Internet Explorer and Netscape


commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.


How can I catch mouse move events both in Internet Explorer and Netscape? I need to keep track of the current position (in pixel coordinates) of the mouse on the document.


You need to see if IE or Netscape is running by checking for document.all or document.layers. Note that the code to access the event coordinates for Netscape 6 is different than for Netscae 4 and 5. Even the event handler registration is different for each browser.

The example works for Netscape 4,5,6 and IE 4,5,6.

<SCRIPT LANGUAGE="JavaScript1.2">
function mouseMoveHandler (evt) {
  var x = document.all ? event.clientX : document.layers ? evt.x : evt.clientX;
  var y = document.all ? event.clientY : document.layers ? evt.y : evt.clientY;
  window.status = x + ':' + y;
if (document.layers)
if (document.layers || document.all)
  document.onmousemove = mouseMoveHandler;
if (document.addEventListener)
  document.addEventListener('mousemove', mouseMoveHandler, true);


2017-12-26, 01:04:48
BernardSeward from India  
I hope this submit will be very effective for the students who are studying in the field of computer science or software. I really valued this information you offered here for us. Actually I am looking for a topic to write an essay as part of my schooling and I which should be a an appealing subject matter additionally. Go to for more writing services.
2018-08-17, 02:30:44
anonymous from United States  



NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: