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 |
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>
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
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
- HTML 4.01 Specification, Section 18.2.3
Event handler parameters
- pEvtObj [in]
- Type: ****IHTMLEventObj****
Attributions
Mozilla Developer Network : [mousemove event Article]
Microsoft Developer Network: [mousemove event Article]