Relegence
asked on
using both onDoubleClick event and onClick event on the same control
Hello,
I am using a c# asp.net application.
I have an image button which i want to do a different operation when clicking and double-clicking the image.
is there a way i can use both onDoubleClick and onClick event for the same control?
The onClick event occurs immediately and i never reach the doubleClick event.
Thank you,
Dana
I am using a c# asp.net application.
I have an image button which i want to do a different operation when clicking and double-clicking the image.
is there a way i can use both onDoubleClick and onClick event for the same control?
The onClick event occurs immediately and i never reach the doubleClick event.
Thank you,
Dana
Yes, when you click on a button,for ex. , before ondblclick event happens onclick event is fired. in such cases, it is difficult to fire ondblclick event. Here you can find smart javascript code that differentiate double click and click. There a special function defines some minute time slap between clicks, if time gap is less than the time slap it triggers double click otherwise single click. Just check it once,
http://www.chipchapin.com/WebTools/JavaScript/example3-01.html
at section >>>Distinguishing Between Click and DblClick on the Same Object
Cheers..
http://www.chipchapin.com/WebTools/JavaScript/example3-01.html
at section >>>Distinguishing Between Click and DblClick on the Same Object
Cheers..
see an example here
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
var dClick=0
function fnTest()
{
setTimeout("ifDbl();", 200);
}
function ifDbl() {
if (dClick==1) {
dClick=0;
return false;
}
alert('a');
}
function fnTest2()
{
alert('b')
dClick=1
return
}
</script>
</head>
<body>
<img src="images.gif" onclick="fnTest();" ondblclick="fnTest2()">
</body>
</html>
<html>
<head>
<script language="JavaScript" type="text/JavaScript">
var dClick=0
function fnTest()
{
setTimeout("ifDbl();", 200);
}
function ifDbl() {
if (dClick==1) {
dClick=0;
return false;
}
alert('a');
}
function fnTest2()
{
alert('b')
dClick=1
return
}
</script>
</head>
<body>
<img src="images.gif" onclick="fnTest();" ondblclick="fnTest2()">
</body>
</html>
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
<input type="button" onclick="alert('xxx'); this.ondblclick()" ondblclick="alert('yyy');"
when onclick fires, ondblclick also will be fired..
cheers