Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 12-27-2005, 11:10 AM   PM User | #1
ottus
New to the CF scene

 
Join Date: Dec 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
ottus is an unknown quantity at this point
How to send parameters for a mousemove event

Hi,
I'm relatively new to JS, but I have some experience with ActionScript. Can anybody explain this to me:

I define a function:

Code:
function myFunction () {something.....;}
And then I want to call it by a event handler:

Code:
document.onmousemove = myFunction();
it doesn't work. Why?

I know, that the correct syntax would be:

Code:
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
ottus is offline   Reply With Quote
Old 12-27-2005, 11:36 AM   PM User | #2
vwphillips
Senior Coder

 
Join Date: Mar 2005
Location: Portsmouth UK
Posts: 4,382
Thanks: 3
Thanked 466 Times in 453 Posts
vwphillips is a jewel in the roughvwphillips is a jewel in the roughvwphillips is a jewel in the rough
var p1='whatever';
var p2=p1;
document.onmousemove =function(){ myFunction(p1,p2); }
vwphillips is online now   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:43 AM.


Advertisement
Log in to turn off these ads.