Skip to content

Instantly share code, notes, and snippets.

@doopz
Last active February 1, 2017 11:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save doopz/d6c50f2233b66b9778ca5ebe3535b645 to your computer and use it in GitHub Desktop.
Save doopz/d6c50f2233b66b9778ca5ebe3535b645 to your computer and use it in GitHub Desktop.
basic obfuscating an email address for the web
* Obfuscating is not going to stop everyone but goes some way to protect your email address from some bots.
* This is a basic implementation which works for me.
* There are 3 parts to it which are as follows:
// css
.obfuscate {
unicode-bidi: bidi-override;
direction: rtl;
}
// javascript
jQuery(document).ready(function ($) {
$("#mailto").on("click", function (event) {
var email = "moc.niamod@enoemos";
$(this).attr('href', 'mailto:' + reverse(email) + '?subject=hello');
});
});
// html
<a id="mailto" class="obfuscate">moc.niamod@enoemos</a>
* This works at the css level to obfuscate the email address and to make the mailto work, we inject the email address on click.
* The email address in the javascript file is also obfuscated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment