Created
March 22, 2018 17:45
-
-
Save elliotaplant/fb3f028500d09150eae36885d137844b to your computer and use it in GitHub Desktop.
How to add event listeners in Internet Explorer 9+
This file contains 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
// From https://stackoverflow.com/questions/20180046/attachevent-doesnt-work-in-ie-8-0 | |
// You can run some feature-checking code to check if the supported features exist: | |
if (window.addEventListener) { | |
// Check for addEventListener first, since IE9/10 have both, | |
// but you should use the standard over the deprecated IE-specific one | |
window.addEventListener('click', myFunc); | |
} else if (window.attachEvent) { | |
window.attachEvent('onclick', myFunc); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment