Safe "Mailto:" links
Those nasty spammers have spiders trawling your site for email addresses to use in their nefarious schemes. David Dorn has a solution all ready to hand for you
Have you ever wondered how it is that you get so much spam in your mailbox? If you've got a Web site and an "Email me" link on there, you've possibly already given those nasty people exactly what they're looking for - your email address.
Having a site without a way of contacting the Webmaster isn't really on, though, so what do you do? Well, here's a little script that will take all the pain away - for the moment, at least:
<script language=javascript>
<!--
var ppclink = "Email me";
var ppcname = "your_name";
var ppchost = "yourisp.co.uk";
document.write("<a href=" + "mail" + "to:" + ppcname + " @" + ppchost + ">" + ppclink + " </a>")
//-->
</script>
And it looks like this on the page (don't worry, the values in the link are dummies anyway - you can't actually use this one):
How does it work?
All you need to do is copy the code, and drop it into the page wherever you want the "mailto" link to go. Then, you need to change a few things - the bits I've coloured red, in fact.
At the "Email me" type in what you want the link to look like - it can be anything, but it's what your visitor will click on to send you email, so make it sensible!
At the "your_name" type in the portion of your email address that comes before the "@" sign - in my case, that would be "PPCUpdate"
Next, at the "yourisp.co.uk" type in the portion of your email address that comes after the "@" sign - in my case that would be "aol.com"
And that's it set up - just save the page, and you'll get a perfectly formed link that works as it should.
No "@"?
That's right - see that " @" that's in the script? That's the HTML code for the "@"character, which you need for an email address. What we're trying to do here is to confuse the spiders and bots that email harvesters use - so, rather than type an email address in, we're having the visitor's browser construct it from the bits of information we give it. Since we're masking the "@" by using its HTML code, rather than the character itself, it's a little bit of icing on the cake.
No doubt the spammers will come up with a way round tricks like this, but they haven't yet, so get those "mailto" links changed ASAP!
You know it makes sense - and now it's easy!


