Created
May 20, 2015 14:08
-
-
Save Munter/24e37c2887021e15e5f7 to your computer and use it in GitHub Desktop.
Always open mailto: links in a new tab. Useful when using webmail clients as mailto: scheme handlers
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
document.body.addEventListener('focus', function (el) { | |
if (el.tagName === 'A' && (el.getAttribute('href') || '').indexOf('mailto:') === 0) { | |
el.setAttribute('target', '_blank'); | |
} | |
}, false); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment