Saturday, November 17, 2007

Using the "onmousemove" event

The "onmousemove" event can help you make sure that your script runs as well as your cursor on the form :) I'll give you a brief example of its usage. We want to trap the cursor's coordinates as it moves in a certain entity's form in CRM.

Add the following code on the OnLoad() event of a form you want:

document.onmousemove = function() {
window.status = event.clientX + "x"+event.clientY;
}



Of course, you may attach the "onmousemove" event to the crmForm too, using:

crmForm.onmousemove = function() {
window.status = event.clientX + "x"+event.clientY;
}


But this way, your status will update only if your cursor moves inside the crmForm, not in the entire window like in our first example.

2 comentarii:

Ciprian Mocanu said...

Ok.. I'm gonna say it :D This is for IE only.. to make it cross-browser things tend to complicate :D

CSC said...

Well, Microsoft Dynamics CRM is made for IE, not firefox, safari etc. That's why I don't complicate things ;)