Last active
August 29, 2015 14:18
-
-
Save Alex1990/d0f2b7447021d9e45b2d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Check if an event is supported. | |
| * Ref: http://perfectionkills.com/detecting-event-support-without-browser-sniffing/ | |
| */ | |
| function isEventSupported(event) { | |
| var testEl = document.createElement('div'); | |
| var isSupported; | |
| event = 'on' + event; | |
| isSupported = (event in testEl); | |
| if (!isSupported) { | |
| testEl.setAttribute(event, 'return;'); | |
| isSupported = typeof testEl[event] === 'function'; | |
| } | |
| testEl = null; | |
| return isSupported; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment