Wednesday, December 26, 2007

Prevent email harvesting by scrambling your email address

Frequently, one may want visitors to our website to email us and the conventional method is to use a mailto: HTML tag like

<a href="">Contact me</a>

which will be displayed by web browsers as

Contact me

However, robotic email harvester will roam the web to harvest email address from such mailto: HTML tags for spam.

There are various ways to prevent this, some more effective than others. One of them is to scramble your email address such that you get a scrambled code like

<script type="text/javascript" language="javascript">
// Email scramble script provided by
{ coded = "wCUvvpdbUdRGKKTph@vKITC.AUK"
key = "sKnQ938wjUCOqGJfaxMZiHd2vANhe1ySWB0EmkY6ztbIol4TuRXVFP7pDrLgc5"
for (i=0; i<coded.length; i++) {
if (key.indexOf(coded.charAt(i))==-1) {
ltr = coded.charAt(i)
link += (ltr)
else {
ltr = (key.indexOf(coded.charAt(i))-shift+key.length) % key.length
link += (key.charAt(ltr))
document.write("<a href='mailto:"+link+"'>Click here to email me</a>")
</script><noscript>Sorry, you need Javascript on to email me.</noscript>

Pasting the scrambled script will cause web browsers to display a link as shown below:

Note: There is some problems. After publishing this post, the "Click here to email me" did not display in FireFox 2.0. It should work if Javascript is enabled, and it is enabled as if Javascript is disabled, you would not be able to see the Google advertisements in this blog.

Viewing this post in Internet Explorer 6 resulted in the following problem. Error message was displayed when trying to load the page in Internet Explorer 6:

Problems with this Web page might prevent it from being displayed properly or functioning properly. In the future, you can display this message by double-clicking the warning icon displayed in the status bar.

Error:Syntax Error
Code: 0

Clicking on the "no entry" Icon in the task bar resulted in this Privacy Report:

Based on your privacy settings, some cookies were restricted or blocked.

Web sites with content on the current page: