- JQuery Tutorials – Use JQuery to protect/rewrite emails from spam bots
- jQuery Tutorials – Hide/protect mailto: links from spam bots and email harvesters #2
- jQuery Tutorials – Hide/protect mailto: links from spam bots and email harvesters #3
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 ;)
1 2 3 4 |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script type="text/javascript"> $(document).ready(function(){email = $('.mail').html(); $('.mail').html(email.replace(/_\[\at\]\_/gi,"@"));}); </script> |
If you want to protect email addresses within the whole document you can try this one.
1 |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script> $(document).ready(function(){ $('body').html($('body').html().replace(/_\[\at\]\_/gi,"@")); }); </script> |
thnx for reading
regards, specktator