Last active
February 1, 2017 11:43
-
-
Save doopz/d6c50f2233b66b9778ca5ebe3535b645 to your computer and use it in GitHub Desktop.
basic obfuscating an email address for the web
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
* 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