[Javascript] Detecting a doubleclick

Peter-Paul Koch gassinaumasis at hotmail.com
Fri May 28 14:51:19 CDT 2004



>I have a page that I am trying to detect the doubleclick event. Each anchor 
>looks like this
>
><a href="#" onclick="dothis(a,x)" ondblclick="dothis2(a,x)">a:x</a>
><a href="#" onclick="dothis(a,y)" ondblclick="dothis2(a,y)">a:y</a>
><a href="#" onclick="dothis(b,z)" ondblclick="dothis2(b,z)">b:z</a>
>...etc
>
>The function dothis2(a,b) basically does a few things then calls 
>dothis(a,b). Is there a way to deteck if a double click took place in 
>dothis(a,b)?

In practice it's nearly impossible to distinguish the two events when 
they're added to one element. This thread showed some interesting possible 
answers, but nonetheless I'm afraid it's not going to work.

It's just too hard for browsers to keep these two events apart. Besides, I 
*think* (but I'm not sure) that one browser (forgot which one) doesn't 
search for more events after having succesfully fired the click event, so 
that it'll never notice the dblclick.

In short: be prepared for a disappointment.

-------------------------------------------------------------------
ppk, freelance web developer
Interaction, copywriting, JavaScript, integration
http://www.quirksmode.org/
Column "Keep it Simple": http://www.digital-web.com/columns/keepitsimple/
------------------------------------------------------------------

_________________________________________________________________
Protect your PC - get McAfee.com VirusScan Online 
http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963




More information about the Javascript mailing list