Closed Bug 90459 Opened 23 years ago Closed 21 years ago

ondblclick event not fired when assigned in JavaScript

Categories

(Core :: DOM: Events, defect, P3)

defect

Tracking

()

VERIFIED FIXED
mozilla1.1alpha

People

(Reporter: Hartmut_Honisch, Assigned: joki)

References

Details

Attachments

(2 files, 1 obsolete file)

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>
<SCRIPT LANGUAGE="JavaScript">
  document.getElementById('element2').ondblclick = new Function('window.alert
("DoubleClick")');
</SCRIPT >
...
Attached file test case
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).
Status: UNCONFIRMED → NEW
Ever confirmed: true
bug 80510?
is it only "ondblclick" or do other events also fail (onclick)?
onclick works fine.
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
Target Milestone: --- → mozilla1.1
*** Bug 112302 has been marked as a duplicate of this bug. ***
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)
DIGBug!!

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?
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"?
joki--is this something that can be easily investigated?
Severity: minor → normal
OS: Windows 3.1 → All
Hardware: PC → All
*** Bug 131862 has been marked as a duplicate of this bug. ***
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>
<script>
document.getElementById('hi').ondblclick = alert('you doubleclicked');
</script>
Maybe this is an easier workaround (and forward compatible):

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

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!? :)
*** Bug 173959 has been marked as a duplicate of this bug. ***
Priority: -- → P3
Attached patch Fix for problem (obsolete) — Splinter Review
ondblclick was missing from the DOM
Attached patch better patchSplinter Review
sorry, bad patch. here's a good one.
Attachment #125033 - Attachment is obsolete: true
Attachment #125034 - Flags: superreview?(peterv)
Attachment #125034 - Flags: review?(bugmail)
Attachment #125034 - Flags: superreview?(peterv) → superreview+
This one is a nobrainer. Function just totally missing from the DOM.
Flags: blocking1.4+
Fix checked in to trunk.
Status: NEW → RESOLVED
Closed: 21 years ago
Resolution: --- → FIXED
Comment on attachment 125034 [details] [diff] [review]
better patch

a=brendan@mozilla.org for 1.4.

/be
Attachment #125034 - Flags: approval1.4? → approval1.4+
Keywords: fixed1.4
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.
Status: RESOLVED → VERIFIED
Keywords: fixed1.4verified1.4
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: