Created
November 14, 2012 14:57
-
-
Save 06b/4072578 to your computer and use it in GitHub Desktop.
Removed Unwanted focus styles from mouse events, but keeps them for tabbed navigation.
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
// Unobtrusive JavaScript: Remove Unwanted Link Border Outlines | |
// http://www.mikesmullin.com/2006/06/16/removing-the-dotted-outline-from-focused-links | |
var runOnLoad = []; | |
window.onload = function () { | |
'use strict'; | |
for (var i = 0; i < runOnLoad.length; i++) { | |
runOnLoad[i](); | |
} | |
}; | |
if (document.getElementsByTagName) { | |
var a = document.getElementsByTagName('a'); | |
for (var i in a) { | |
a[i].onmousedown = function () { | |
'use strict'; | |
this.blur(); // most browsers | |
this.hideFocus = true; // internet explorer | |
this.style.outline = 'none'; // mozilla | |
}; | |
a[i].onmouseout = a[i].onmouseup = function () { | |
'use strict'; | |
this.blur(); // most browsers | |
this.hideFocus = false; // internet explorer | |
// Only run if not IE8. This just feels so dirty. | |
/*@cc_on | |
@if (!(@_jscript_version === 5.8)) { | |
this.style.outline = null; // mozilla | |
} | |
@end | |
@*/ | |
}; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment