Skip to content

Instantly share code, notes, and snippets.

@06b
Created November 14, 2012 14:57
Show Gist options
  • Save 06b/4072578 to your computer and use it in GitHub Desktop.
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.
// 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