Firefox does not support events on disabled input elements (see: Event on a disabled input) but every other browser I've tested (IE8, Chrome, Opera, Safari5) do support it. The trouble is, I wish to use an onClick event via event delegation to enable the disabled elements (demo: http://codepen.io/cimmanon/pen/Emkwo).
The recommended solution is to overlay an element on top of the disabled element and use it to intercept the click events. I'd like to inject the overlay via JavaScript, since going through and modifying all instances of my disabled elements is more trouble than it's worth (plus it pollutes my markup, which I don't really like).
Is there a way to detect whether or not a browser supports what I'm doing and only inject the overlay in those browsers? I thought I could do something like this, but Firefox gives a false positive:
var foo = document.getElementById('foo');
foo.onclick = function(e) {
return true;
}
if (foo.onclick()) {
console.log('browser supported!');
}