Hidding email addresses from Spammers

Spam is already out of control and it’s virtually impossible not to get any spam. But there are ways to help prevent your address from being copied from your website. I use a little JavaScript.

Here is the function that I have in my utilities.js file;

  1. function showAddress(add) {
  2. address_to_replace=document.getElementById(add).firstChild;
  3. real_address=address_to_replace.nodeValue.replace("_at_", "@");
  4. address_to_replace.nodeValue=real_address;
  5. address_to_replace.parentNode.setAttribute("href", "mailto:"+real_address);
  6. }
  7. }
  8. window.onload = function() { howAddress('email1'); }

Then all you need to do is create your mailto link like this;

  1. <a id="email1">me_at_mydoamin.com</a>

Now when the page loads this JavaScript function will replace this text “_at_” in the element with an ID of “email1″ with an @ symbol.

This prevents bots and spiders from finding your email address.

This entry was posted on Sunday, February 4th, 2007 at 10:45 pm and is filed under Web Design. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

 

Leave a Reply