Last active
August 29, 2015 14:20
-
-
Save cowboymathu/d79e742718994bf2daa6 to your computer and use it in GitHub Desktop.
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 escapeAll(str) { | |
var hexString = ""; | |
for (var index=0; index<str.length; index++) { | |
var charCode = str.charCodeAt(index); | |
var h = charCode.toString(16).toUpperCase(); | |
if (h.length == 1) { | |
h = "0" + h; | |
} | |
h = "%" + h; | |
hexString += h; | |
} | |
return hexString; | |
} | |
jQuery(function() { | |
jQuery('a[href^="mailto:"]').each(function() { | |
var url = this.href.split("mailto:"); | |
var email = url[1].split('@'); | |
urlToEscape = email[0] + '@'; | |
this.href = "mailto:" + escapeAll(urlToEscape) + email[1]; | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment