Skip to content

Instantly share code, notes, and snippets.

@nielk
Last active December 30, 2015 05:59
Show Gist options
  • Save nielk/7786289 to your computer and use it in GitHub Desktop.
Save nielk/7786289 to your computer and use it in GitHub Desktop.
liens d'évitement cross browser (IE8+)
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