Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2005
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,505
    Thanks
    3
    Thanked 501 Times in 488 Posts
    var p1='whatever';
    var p2=p1;
    document.onmousemove =function(){ myFunction(p1,p2); }


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •