-
July 20th, 2007, 03:48 AM
#1
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
-
July 20th, 2007, 04:18 AM
#2
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.
-
July 20th, 2007, 04:18 AM
#3
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">
-
July 20th, 2007, 04:21 AM
#4
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.
-
July 20th, 2007, 06:21 AM
#5
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|