...

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



ottus
12-27-2005, 11:10 AM
Hi,
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

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



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum