Protect your email address from spiders!
You may not realize it, but if your full email address is included in the source code of a web page, it's fair game for web crawling robot spiders (oh no! spiders!) to come along and add it to email spam lists. Thankfully theres a relatively simple way to protect your address with some JavaScript.
The function: prEmail()
- // hide email address from spiders
- function prEmail(user,domain,show) {
- addy = user + "@" + domain;
- display = (show)? show : addy;
- document.write("<a href=\"mailto:"+addy+"\" title=\""+addy+"\">"+display+"</a>");
- }
- source file: email-protection.txt
Now let's say your email address is bob@ack_spiders.com and you want the email link to say "e-mail Bob". To include your address safely, call prEmail() this way:
- <p>Hey guys! If you have any questions, please <script type="text/javascript">prEmail('bob','ack_spiders.com','e-mail Bob');</script> right away!</p>
You can also leave out the third argument to display the actual address as the link text. Happy obfuscation!