[AccessD] OT: Stopping spammers on your website using JavaScript

Bob Gajewski rbgajewski at adelphia.net
Sat Jun 26 13:12:15 CDT 2004


NO ARCHIVE

For those of you that have websites, and have emails addresses in your
source code ...

There are many email address 'harvesters' out there that simply troll your
HTML source code looking for valid email addresses (name at domain.com). They
then sell lists of these addresses to anyone willing to buy them - usually
spammers.

Although this solution is not new by any means, I have finally got it up and
working on my sites - and it works great! This will prevent 99% of these
harvesters from ever finding your actual email addresses, yet lets users
link seamlessly.

WATCH FOR LINE WRAP

Step 1 - Create an external JavaScript file ("tools.js" or whatever you want
to name it). Put it in your web host root directory.

	function sendMail(n2,d2,e2,s2,b2){
		var r2 = 'mailto:' + n2 + '@' + d2 + '.' + e2 + '?subject=' + s2 +
'&body=' + b2;
		document.location.href = r2;
		}

Step 2 - Add a call to the external file in each of your web pages. Place
this AFTER the </head> tag and BEFORE the <body> tag.

	<script language="JavaScript" src="tools.js"></script>

	NOTE: If any of your pages are in subfolders, you will have to alter the
'src' tag accordingly. For example, let's say you have a web page
"download.html" in your "download" subfolder. Modify your tag as follows:

	<script language="JavaScript" src="../tools.js"></script>

	The "../" tells your subpage to look in your main folder for the external
JavaScript file.

Step 3 - Modify your email hyperlinks as follows:

	FROM EXAMPLE:

		<a href="mailto:name at domain.com?subject='Feedback'&body='Input your
comments here'">Feedback</a>

	TO EXAMPLE:

		<a href="javscript:sendMail('name','domain','com','Feedback','Input your
comments here');">Feedback</a>

Of course, the Subject and Body fields are optional. If you want to omit
either of them, simply use '' in the code. You must ALWAYS pass the full
five parameters, even if they are blank.

	NO SUBJECT EXAMPLE:

		<a href="javscript:sendMail('name','domain','com','','Input your comments
here');">Feedback</a>

	NO BODY EXAMPLE:

		<a
href="javscript:sendMail('name','domain','com','Feedback','');">Feedback</a>

	NO SUBJECT OR BODY EXAMPLE:

		<a href="javscript:sendMail('name','domain','com','','');">Feedback</a>


I hope that this helps any of you eliminate getting spammed from your web
page email links.

Regards,
Bob Gajewski






More information about the AccessD mailing list