Closed Bug 598031 Opened 14 years ago Closed 14 years ago

The "in" operator returns false for event names on DOM objects

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 414853

People

(Reporter: andyearnshaw, Unassigned)

Details

User-Agent:       Mozilla/5.0 (compatible; MSIE 9.0; Windows NT 6.1; WOW64; Trident/5.0)
Build Identifier: 

Consider the following code:

    alert("onclick" in document.documentElement);

This will log "true" in all browsers except for Firefox.  The same goes for testing DOM event availability in general, all other major browsers implement the events on the element prototype chain.

Reproducible: Always

Steps to Reproduce:
1. Enter the above code in the Firebug console or in the address bar with the javascript: label.
Actual Results:  
The output is `false`

Expected Results:  
The output should be `true`

The following site goes into more detail on the subject, including a work around:

http://perfectionkills.com/detecting-event-support-without-browser-sniffing/

I believe that Mozilla's DOM implementation should be updated to improve interoperability between browsers.
Status: UNCONFIRMED → RESOLVED
Closed: 14 years ago
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.