Home » Archives » February 2005 » Spammed Out?
[Previous entry: "Do Not Execute"] [Next entry: "BBCode?"]
Spammed Out? - or
Prevent Spam Email Crawlers from Harvesting Your Site
category: spamming, javascript
I don't know about you, but my delete key is wearing out. If you have your email address displayed on a web page, then here is some javascript that will help you slow the spammers down a little. What it does is create your email link when your page loads, providing no email address for spam crawlers to harvest. I don't know how smart these crawlers have become, so I have used silly variable names, an "%40" instead of the typical "@" sign, and spread the relevant components around a little. This may be a little paranoid, but as I said, my delete key...
This part goes in the head of your document:
<script language="Javascript">
<!--
// these two variables are used in the email address creation, put
// them in the head of your document with your other javascript.
//
last = "yourdomain.com";
badword = "'mailto:";
//-->
</script>
This part goes in place of your email link:
<p class="links">
<script language="Javascript">
<!--
// Put this code in the body of your page in place of you email link,
// and style it however you like. "doodaa" is your email address to
// the left of the @ sign. "Email Myname" is what appears on your page.
doodaa = "myname";
document.write("<a href=" + badword + doodaa + "%40"
+ last + "'>");
document.write("Email Myname");
document.write("</a>");
//-->
</script>
</p>
Good Luck.
He said on 02.21.05 @ 04:25 PM CST
