onClick, onDblClick have different interpretations in IE, Firefox AND Opera. What to do?

Posted on 2006-05-05
Last Modified: 2008-01-09
I have a webpage that cyales through preloaded frames (div) as a user presses the *next* and *back* form buttons.

I need it to work properly in IE and Firefox. What is the best possible way to facilitate this?

Here is what happens in the different situations:

1. If I simply assign he "onclick" button to call the function for the button:

IE 6 - The first click flips it but if the second follows too sortly (users cycling frames quickly) the second or every other buton click does not trigger the "onClick" handler.

Firefox - The first click and all other clicks perform normally (this is the behavior I WANT!)

Opera 9.0 beta - Same as IE - DOESN'T register the second swift click.

2. If I assign the SAME function to handle BOTH the onClick and onDblClick events:

IE 6 - Behaves Properly (first, second, ... clicks all go to next page)

Firefox -  Now, when i click for the second time it counts as a singl click AND a double click. It flips TWO pages on the second click!

Opera 9.0 beta - STILL DISPLAYS THE SAME BEHAVIOR AS BEFORE - UNBELIEVEABLE!!! It still doesn't flip on the second click!!!! What is wrong with this browser??? I don't even care because this is an internal page and my company doesn't support Opera, but seriously... This is a definate bug.

So the real question is: What is the easiest way/best practice for making this work properly in both IE and Firefox? I want to avoid a real 'hack' if possible. Thanks.
Question by:mobrien118
    LVL 63

    Accepted Solution

    Try removing all clicks and use: onMouseDown

    Author Comment

    Thanks Zvonko. I am kicking myself for not thinking of that.

    Your answer actually inspired me to do something else, though. I am using onMouseUp instead, so it acts a little bit more like the button is actually supposed to. The only 'problem' with this is that you can actually click down somewhere else and let up on the botton and it will still perform its action. This is a pretty minute proplem in most cases, including mine. I would give half the expert points to me, but I can' do that so here you go. Good job.

    I am still quite purturbed that these browsers can't act responsibly. In my opinion they all exhibit buggy behavior. A single click should be a single click, and the second click should be a double click and NOT a single click if there already was one. I guess it depends on the situation, though. I would venture to say that IE actually got this one right (not meant to start a discussion as that is for the message boards). And what the heck is Opera even doing?
    LVL 63

    Expert Comment

    You are welcome.
    And you are right that browser GUI is not perfect.
    But what I try to clarify is that people expect too much. A browser was basically a TEXT display application with the ability to open new text file on click on marked words. That was all what you got for free. Now many people ask why you cannot draw and paint with the universal browser, and configure that paint behaviour by JavaScript, VBScript, Perl and so on. The GUI was never designed to be a dynamic Application creator. It got step by step become an Application creation interface, but do not forget that basic usage was and is to display Text streams, not more and not less.

    See you,


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
    In Part 1 ( we covered the hexagonal maze basics -- how the cells are represented in a JavaScript array and how the maze is displayed.  In this part, we'…
    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…

    761 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

    Need Help in Real-Time?

    Connect with top rated Experts

    8 Experts available now in Live!

    Get 1:1 Help Now