Last active
December 30, 2015 05:59
-
-
Save nielk/7786289 to your computer and use it in GitHub Desktop.
liens d'évitement cross browser (IE8+)
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
if (!window.addEventListener) { | |
window.attachEvent("onhashchange", function(event) { | |
var element = document.getElementById(location.hash.substring(1)); | |
if (element) { | |
if (!/^(?:a|select|input|button|textarea)$/i.test(element.tagName)) { | |
element.tabIndex = -1; | |
} | |
element.focus(); | |
} | |
}, false); | |
} | |
else { | |
window.addEventListener("hashchange", function(event) { | |
var element = document.getElementById(location.hash.substring(1)); | |
if (element) { | |
if (!/^(?:a|select|input|button|textarea)$/i.test(element.tagName)) { | |
element.tabIndex = -1; | |
} | |
element.focus(); | |
} | |
}, false); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment