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;
- function showAddress(add) {
- address_to_replace=document.getElementById(add).firstChild;
- real_address=address_to_replace.nodeValue.replace("_at_", "@");
- address_to_replace.nodeValue=real_address;
- address_to_replace.parentNode.setAttribute("href", "mailto:"+real_address);
- }
- }
- window.onload = function() { howAddress('email1'); }
Then all you need to do is create your mailto link like this;
- <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.