ondblclick event not fired when assigned in JavaScript

VERIFIED FIXED in mozilla1.1alpha



DOM: Events
17 years ago
15 years ago


(Reporter: Hartmut Honisch, Assigned: joki (gone))


Bug Flags:
blocking1.4 +

Firefox Tracking Flags

(Not tracked)



(2 attachments, 1 obsolete attachment)



17 years ago
The A.OnDblClick event doesn't get fired when it is assigned via JavaScript. 
Here is a (non-working) example:
<A id="element2" href="#">Dblclick me</A>
  document.getElementById('element2').ondblclick = new Function('window.alert

Comment 1

17 years ago
Created attachment 42061 [details]
test case

Comment 2

17 years ago
I can confirm this bug with the 20010710 nightly on Windows 2000. All
doubleclick items in the testcase fail.

The reporter does not mention it, but assigning the event in HTML, such as with
<a href="#" ondblclick="window.alert('DoubleCLick')">DoubleClick Me</a> works
fine with this build (contrary to the report in bug 85518). So this looks to be
a problem strictly with JavaScript DOM assignment of the ondblclick event.

I cannot find a duplicate that is related to JavaScript assignment of the event.
Bug 29473 seems to be both Mac specific and related to particular Input elements
(not A).
Ever confirmed: true

Comment 3

17 years ago
bug 80510?
is it only "ondblclick" or do other events also fail (onclick)?

Comment 4

17 years ago
onclick works fine.

Comment 5

16 years ago
This bug still exists in Build 2001-09-14-05-0.9.4 on Windows 2000 Service pack 
1.  A.OnDblClick event doesn't get fired. 
OS: Windows 98 → Windows 3.1


16 years ago
Target Milestone: --- → mozilla1.1

Comment 6

16 years ago
*** Bug 112302 has been marked as a duplicate of this bug. ***

Comment 7

16 years ago
This bug affects Windows2000 - still a problem in RC2.  It seems that this is a
major bug and should be fixed by 1.0.  Several of our sites rely on the
ondblclick event and have had to be tweaked (using onclick) just to make them
work with Netscape 6.  Was really hoping that this would be fixed in Mozilla 1.0
and next version of Netscape!
This worked fine in Netscape 4.
Please switch OS field to All (its not just Windows 3.1)

Comment 8

16 years ago

Has there been any progress on this bug?  Its been opened since 7/12/2001.
I tested this bug on Mozilla 2002041617 and it still doesn't work.

The only workaround that I'm aware of is the following:
   1) Register for the onclick handler
   2) Check the event detail to see if its == 2
   3) If it is, call your ondblclick handler.

For example:
    // Doesnt work on NS6, workaround to use onclick
    // table.ondblclick = mydblclickHandler;
    table.onclick = function(evt) {
        if (evt.detail == 2) mydblclickHandler(evt);

On double click handlers are used throughout all of our DIG applications.
This would be a useful fix.

Is my suggested workaround the recommened way to workaround this bug?

Comment 9

16 years ago
I wonder if nobody is bothering to look into this bug because OS is listed as
Win3.1 and severity as minor.  Can somebody switch the OS field to "All" and
severity to "normal" or "major"?

Comment 10

16 years ago
joki--is this something that can be easily investigated?
Severity: minor → normal
OS: Windows 3.1 → All
Hardware: PC → All

Comment 11

16 years ago
*** Bug 131862 has been marked as a duplicate of this bug. ***

Comment 12

16 years ago
I've just encountered this bug in Mozilla 1.1 alpha running on Windows XP - my
attempts to attach an ondblclick event to various elements through javascript
all failed:

<div id="hi">double click me!</div>
document.getElementById('hi').ondblclick = alert('you doubleclicked');

Comment 13

16 years ago
Maybe this is an easier workaround (and forward compatible):

var el=document.getElementById('hi');
if (el.addEventListener)
  el.addEventListener("dblclick", hello, false)
  el.ondblclick = hello;

Comment 14

16 years ago
Considering how simple the workaround in comment #8 is, could the actual bug fix
be just as simple?  Could somebody please investigate?  Its a regression from
NS4 and support for a basic DOM event, and its been open for over a year now,
and targetted 1.1alpha! 
Please!? :)

Comment 15

15 years ago
*** Bug 173959 has been marked as a duplicate of this bug. ***


15 years ago
Priority: -- → P3

Comment 16

15 years ago
Created attachment 125033 [details] [diff] [review]
Fix for problem

ondblclick was missing from the DOM

Comment 17

15 years ago
Created attachment 125034 [details] [diff] [review]
better patch

sorry, bad patch. here's a good one.
Attachment #125033 - Attachment is obsolete: true


15 years ago
Attachment #125034 - Flags: superreview?(peterv)
Attachment #125034 - Flags: review?(bugmail)
Attachment #125034 - Flags: superreview?(peterv) → superreview+
Attachment #125034 - Flags: review?(bugmail) → review+

Comment 18

15 years ago
This one is a nobrainer. Function just totally missing from the DOM.
Flags: blocking1.4+

Comment 19

15 years ago
Fix checked in to trunk.
Last Resolved: 15 years ago
Resolution: --- → FIXED


15 years ago
Attachment #125034 - Flags: approval1.4?
Comment on attachment 125034 [details] [diff] [review]
better patch

a=brendan@mozilla.org for 1.4.

Attachment #125034 - Flags: approval1.4? → approval1.4+


15 years ago
Keywords: fixed1.4

Comment 21

15 years ago
Using winxp branch build 20030612 and linux trunk build 20030611 this fixed per
attached test case in comment 1  
Verified branch and trunk
Note: with builds  before fix I did see the problem using test case.
Keywords: fixed1.4 → verified1.4
You need to log in before you can comment on or make changes to this bug.