Don’t you really hate it when you put your email address online and bots start to spam it? Me too! Upon launching a new site, I decided to do something about it.
Here is a very simple script that displaces the issue of having mailto: links laying about in your code for spam bots to pick up.
function hide_email()
{
//create regular expression
var regular_expression = new RegExp(”[Mm]ailto”);
//start by checking all links
for(var count=0; count<document.links.length; count++)
{
//is this an email link??
if(regular_expression.test(document.links[count].href))
{
try {
//move email link for safe keeping
document.links[count].name = document.links[count].href;
//replace email link with nonsense
document.links[count].href=”mailto:nospam@nospam.com”;
//keep valid users happy (yay!)
document.links[count].onmouseover = function() { this.href = this.name; };
//keep spammers away (boo bots!)
document.links[count].onmouseout = function() { this.href=”mailto:nospam@nospam.com”; };
}catch (err) {
//oh noes! something bad happened.
}//end catch
}//end if
}//end for loop
}//end hide email
hide_email(); //make function call to execute
Now put this script, right before the </body> (yes ending body tag) tag and it will scour your web page for all mailto: links and save them from bot doom. Of course this isn’t an extremely secure fix, but it’ll do the job against those stupid bots until they get smarter.
Final Note: If you’re using my script for tooltips, then these two aren’t compatible together yet. I think I understand the problem, but it’ll take some testing to verify. Just give me some time and I’ll make a post with new versions.