Tech or Treat! Write an article about your scariest tech disaster to win gadgets!Learn more


Ignore onMouseDoubleClick to allow for rapid onMouseDown event captures (IE only)

Posted on 2008-06-11
Medium Priority
Last Modified: 2008-06-20
I have an online javascript calculator that uses html/CSS for the GUI buttons.  These calculator buttons are using onmousedown to capture the user clicking on the GUI.  This works great, but in IE, if the user clicks very quickly (for example types the number "1.333") then IE interprets the clicking of the "3s" as a doubleclick event and I do not get the correct number of onmousedown events.  This is extremely annoying and only in IE.  (FF, Safari, and Opera all process the event with the correct number of onmousedown events.)

I've done some research into what events are being fired for IE.  If you do two quick clicks you fire the following sequence of events:

mousedown fired... Then mouseup fired... Then click fired... Then mousedown fired... Then mouseup fired... Then click fired... Then dblclick fired...

So it appears as if the dblclick event trumps any mouedown events.

What approach should I take to this problem?  Again, this seems to be an IE only problem but I need this solution to work correctly in conjunction with all the other browsers that work fine.

Question by:proee
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Accepted Solution

robacarp earned 1500 total points
ID: 21765991
I may be oversimplifying the problem, but you could setup your dblclick handler to fire your click handler twice:
[example psuedo javascript]
function clickFunc(){
   //do stuff 
function dblClickFunc(){
   if ( != 'Internet Explorer') return;
button.onclick = clickFunc;
button.ondblclick = dblClickFunc;
/* or something like that.... its an example, not working code */

Open in new window


Author Comment

ID: 21766015
I've thought about this approach.  Wondering if there might be less of a "hack" than this.  I have a lot of buttons on the calculator gui so I'd have to add a ton of onmousedblclick handlers all over.  I was hoping to handle it with an event capture somehow.  Thanks for the suggestion, I'll try it if I don't hear of a better approach.

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nothing in an HTTP request can be trusted, including HTTP headers and form data.  A form token is a tool that can be used to guard against request forgeries (CSRF).  This article shows an improved approach to form tokens, making it more difficult to…
This article discusses how to implement server side field validation and display customized error messages to the client.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

648 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question