Detecting DOM event support in Firefox
- by Andy E
What's the best way to detect event support in Firefox. Opera, Internet Explorer and Safari/Chrome all support eventName in object, but Firefox doesn't. My test case is this:
javascript:alert("onclick" in document.createElement("a"))
Which alerts true when entered into the address bar on the aforementioned browsers, and alerts false for Firefox. I figured out a solution using typeof on an event like so:
var a = document.createElement("a");
a.setAttribute("onclick", "");
alert(typeof(a.onclick) == "function");
Is there a better method of detecting event support in Firefox?