Detecting support for a given JavaScript event?

Well, the best approach is not going through browser sniffing, Juriy Zaytsev (@kangax) made a really useful method for detecting event support: var isEventSupported = (function(){ var TAGNAMES = { ‘select’:’input’,’change’:’input’, ‘submit’:’form’,’reset’:’form’, ‘error’:’img’,’load’:’img’,’abort’:’img’ } function isEventSupported(eventName) { var el = document.createElement(TAGNAMES[eventName] || ‘div’); eventName=”on” + eventName; var isSupported = (eventName in el); if (!isSupported) { … Read more

Best way to detect that HTML5 is not supported

This is the technique used in Modernizr and basically every other library that does canvas work: function isCanvasSupported(){ var elem = document.createElement(‘canvas’); return !!(elem.getContext && elem.getContext(‘2d’)); } Since your question was for detection when it’s not supported, I recommend using it like so: if (!isCanvasSupported()){ …