When using createEvent, an eventType parameter must be provided as an
argument. This can be one of those specified in DOM 2 or 3 Events, or
it might be a proprietary eventType[1].
My problem is testing for support of particular eventTypes - the DOM 2
Events Interface DocumentEvent says that if the eventType is not
supported, it throws a DOM exception[2]. This makes testing rather
tough - if you try something like:
if (document && document.create Event &&
document.create Event(eventType )) {...}
or a typeof test and the eventType (say 'MouseEvents') isn't
supported, the script crashes with a DOM execption as specified in the
DOM 2 Events spec. I can do try..catch but I'd rather not if I can
avoid it:
var eventType = 'MouseEvents';
try {
document.create Event(eventType );
alert(eventType + ' OK');
} catch (e) {
alert(eventType + ' not supported by createEvent');
return;
}
Is there a feature test that can be used?
1. Gecko supporte eventTypes:
<URL: http://developer.mozilla.org/en/docs...nt.createEvent
2. W3C DOM 2 Events: Interface DocumentEvent - createEvent
<URL: http://www.w3.org/TR/DOM-Level-2-Eve...nt-createEvent
--
Rob
argument. This can be one of those specified in DOM 2 or 3 Events, or
it might be a proprietary eventType[1].
My problem is testing for support of particular eventTypes - the DOM 2
Events Interface DocumentEvent says that if the eventType is not
supported, it throws a DOM exception[2]. This makes testing rather
tough - if you try something like:
if (document && document.create Event &&
document.create Event(eventType )) {...}
or a typeof test and the eventType (say 'MouseEvents') isn't
supported, the script crashes with a DOM execption as specified in the
DOM 2 Events spec. I can do try..catch but I'd rather not if I can
avoid it:
var eventType = 'MouseEvents';
try {
document.create Event(eventType );
alert(eventType + ' OK');
} catch (e) {
alert(eventType + ' not supported by createEvent');
return;
}
Is there a feature test that can be used?
1. Gecko supporte eventTypes:
<URL: http://developer.mozilla.org/en/docs...nt.createEvent
>
<URL: http://www.w3.org/TR/DOM-Level-2-Eve...nt-createEvent
>
--
Rob
Comment