View Full Version : How to send parameters for a mousemove event

12-27-2005, 12:10 PM
I'm relatively new to JS, but I have some experience with ActionScript. Can anybody explain this to me:

I define a function:

function myFunction () {something.....;}

And then I want to call it by a event handler:

document.onmousemove = myFunction();

it doesn't work. Why?

I know, that the correct syntax would be:

document.onmousemove = myFunction;

WITHOUT ANY PARAMETERS. Why is this correct?
And how is it possible to pass any parameters to my function (if it was pe.: myFunction(someParameter) {blabla.....;}

Thanks for explanation.
Bye, Kozelnik

12-27-2005, 12:36 PM
var p1='whatever';
var p2=p1;
document.onmousemove =function(){ myFunction(p1,p2); }