how to call javascript function on mouseclick
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5

Thread: how to call javascript function on mouseclick

  1. #1
    Join Date
    Jul 2007
    Posts
    9

    how to call javascript function on mouseclick

    Hi

    I want to call 2 different javascript function at a time on mouse click event.
    Is there is any possibility to do this

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,858

    Re: how to call javascript function on mouseclick

    Well, you can grab it in a tag. It is called onclick. Or you can set it with JavaScript.

    Code:
    <whatever_tag ... onclick="function(parameters)">
    
    or
    
    <script type="text/javascript">
    document.onclick = function();
    or
    document.getElementById(...).onclick = function();
    </script>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Jun 2004
    Location
    Kashmir, India
    Posts
    6,808

    Re: how to call javascript function on mouseclick

    Yes there is. Something like this
    Code:
    <input type="text" id="text1" name="text1" onblur="function1(this.value); function2(this.value); function3(this.value); value = "Some Value">

  4. #4
    Join Date
    Jul 2007
    Location
    Sweden
    Posts
    331

    Re: how to call javascript function on mouseclick

    To call two functions at once in the event, you can put them in an anonymous/lambda function (in element attributes you don't have to - it executes JavaScript if it's not a function name):
    Code:
    document.onclick = function () { func1(); func2(); };
    // - or -
    <a href="#" onclick="func1(); func2();">Link</a>
    Note that in anonymous functions, the this keyword loses its scope. This can be solved using the call() method of the Function object:
    Code:
    element.onclick = function () { func1.call(element); func2.call(element); };
    Using this with the above code will now refer to the element object.
    Last edited by andreasblixt; July 20th, 2007 at 04:24 AM.

  5. #5
    Join Date
    Jul 2007
    Posts
    9

    Re: how to call javascript function on mouseclick

    Hi guy's

    Thank's for u kind help

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center