This jquery snippet protects your published email addresses from being obtained from spam bots. Keep in mind that your (html)code must be in form Peter_[at]_example.com and the emails must be inside an ellement with mail class in order to let javascript replace the correct characters. Of course you can modify it as you wish ;) […]
Series: Spambot Protection
jQuery Tutorials – Hide/protect mailto: links from spam bots and email harvesters #2
Here is a jQuery snippet that can protect email addresses from email harvesters. All you need to do is to inlcude .mail class to your “mailto:” html links like the example below.
1 |
<a href="mailto:peter_[at]_example.com" class="mail"> peter_[at]_example.com </a> |
1 2 3 4 5 6 |
$(document).ready(function(){ mailto = $("a[href^='mailto:']").attr('href'); $("a[href^='mailto:']").attr('href',mailto.replace(/_\[\at\]\_/gi,"@")); email = $('.mail').html(); $('.mail').html(email.replace(/_\[\at\]\_/gi,"@")); }); |
Geeks are sexy… :D @specktator
jQuery Tutorials – Hide/protect mailto: links from spam bots and email harvesters #3
Here is a jQuery snippet that can protect email addresses from email harvesters. All you need to do is to inlcude .mail class to your “mailto:” html links like the example below.
1 |
<a href="mailto:peter_[at]_example.com"> peter_[at]_example.com </a> |
1 2 3 4 5 6 7 8 9 |
jQuery(document).ready(function(){ mailtoellements = jQuery("a[href^='mailto:']"); mailtoellements.each(function(item){ mailto = jQuery(this).attr('href'); jQuery(this).attr('href',mailto.replace(/_\[\at\]\_/gi,"@")); email = jQuery(this).html(); jQuery(this).html(email.replace(/_\[\at\]\_/gi,"@")); }); }); |
line 2: Gather all the elements with the matched criteria line 3: Iterate on these elements line 4: on each […]