Created
August 8, 2020 00:38
-
-
Save magdielndantas/006e37ec47a2103d3f8435655266b426 to your computer and use it in GitHub Desktop.
With this code, you’ll remove the outline if you use the mouse, and if you use the keyboard, you’ll enable back all the outlines.
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
(function(document, window){ | |
if (!document || !window) { | |
return; | |
} | |
var styleText = '::-moz-focus-inner{border:0 !important;}:focus{outline: none !important;'; | |
var unfocus_style = document.createElement('STYLE'); | |
window.unfocus = function(){ | |
document.getElementsByTagName('HEAD')[0].appendChild(unfocus_style); | |
document.addEventListener('mousedown', function(){ | |
unfocus_style.innerHTML = styleText+'}'; | |
}); | |
document.addEventListener('keydown', function(){ | |
unfocus_style.innerHTML = ''; | |
}); | |
}; | |
unfocus.style = function(style){ | |
styleText += style; | |
}; | |
unfocus(); | |
})(document, window); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment