This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

mousemove

Summary

Fires when the user moves the mouse over the object.

Overview Table

Synchronous No
Bubbles Yes
Target dom/Element
Cancelable No
Default action none
## Examples

This example uses the onmousemove event to monitor the location of the mouse cursor on the screen. When the mouse cursor moves over the div object, a span object is updated with the clientX and clientY property values. The clientX and clientY properties are exposed by the event object.

<script type="text/javascript">
function fnTrackMouse(){
   oNotice.innerText="Coords: (" + event.clientX + ",
      " + event.clientY + ")";
}
</script>
<div id="oScratch" onmousemove="fnTrackMouse()">
  <span id="oNotice"></span>
</div>

View live example

Add mouse crosshairs to a web page when a checkbox is clicked.

function moveCrosshairs(evt){
         if(!evt)evt=window.event;
         var posx = 0; var posy = 0;
         if(document.documentMode&&document.documentMode>=9){
         posx+=parseInt(document.documentElement.style.marginLeft+0);
         posy+=parseInt(document.documentElement.style.marginTop+0);
         }
         if (evt.pageX

View live example

Notes

Remarks

If the user presses a mouse button, use the button property to determine which button was pressed. Initiates any action associated with this event. To invoke this event, do one of the following:

  • Move the mouse over the document.

Syntax

Standards information

Event handler parameters

pEvtObj [in]
Type: ****IHTMLEventObj****

Attributions