JavaScript To Hide Your EMail From Spambots

Get Help With All Aspects of Web Design & Design Software

Moderators: Moderator, Global Moderator

Post Reply
Tami
Administrator
Administrator
Posts: 10892
Joined: Sun Apr 25, 2004 1:05 pm

JavaScript To Hide Your EMail From Spambots

Post by Tami »

javascript To Hide Your EMail From Spambots By Ed Zivkovic Ever wander why so many webmasters refuse to insert their email address into the body of their webpages? The reason is to protect their eMail address from email harvesting robots. These robots crawl the Internet searching for email addresses in order to build a spam list. These spambots ignore the robots.txt file. The robots.txt file is used to instruct legitimate web crawling robots about where they can and cannot go on your site. The file is observed by honest search engine robots but not by spambots. Spambots will also ignore any instructions within the meta tags of your HTML. This means that they just go around doing what they want violating your rights as a webmaster. Spambots are boundary violators just like the spammers who continue to do what they do. That is, send spam. Many webmasters today have decided to use a contact form instead in an attempt to throw the spambots off. This has served a dual purpose for Internet marketers. 1. To keep the eMail address safe from spambots. 2. Another webpage to use for the purpose of channeling Page Rank (PR). The contact form works fine, but just in case you find the need to add your eMail address into your webpages, you can use some javascript to hide the eMail from the spambots. Below you will discover two Free javascript resources. These javascripts are easy to use if you have access to the HTML of your webpages. They can be added to any webpage quickly and easily. The Unspamable eMail Link javascript If you would like to display your eMail link to humans but hide it from spambots, you can use this Free cut-and-paste Unspamable email link javascript from: [code]<script language="javascript"><!-- var name = "protected"; var domain = "cdrsoft.com"; document.write(\'<a href=\"mailto:\' + name + \'@\' + domain + \'\">\'); document.write(name + \'@\' + domain + \'</a>\'); // --></script>[/code] [url=\"http://www.javascriptkit.com/script/script2/unspam.shtml\"]Code Source[/url] How to Edit the javascript Select the javascript from the textarea then copy and paste it into your HTML document. You will notice two variables within the script: [code]var name = "protected"; var domain = "cdrsoft.com";[/code] To insert the email address webmaster@yourdomain.com, simply replace the word \"protected\" with the word \"webmaster\" and replace the domain \"cdrsoft.com\" with \"yourdomain.com\". That\'s it. Automatic Encoding Tool This tool is easy to use. Just insert the email address you wish to protect and click the button called \"Encode mail links\": [url=\"http://www.bronze-age.com/nospam/encode.html\"]http://www.bronze-age.com/nospam/encode.html[/url] Also, you will need to download a small file called \"email.js\" and upload it to your website. [attachment=655:attachment\" target=\"_blank\">[u] This file should be added to a suitable directory, such as the root or a scripts directory, within your web site. It is very small (less than 1K) so will not adversely affect page-load times. To use the script to protect email links in a web page you need to carry out the following steps: 1. In the HEAD section of the web page, add the following line: [code]<script language="javascript" src="/scripts/email.js"></script>[/code] You must be careful to specify the correct path to the email.js file - here I\'ve assumed you\'ve saved it into a top-level \"scripts\" directory in your site. Now, every email link must be converted to a script call. For instance, a link such as: [code]<a href="mailto:nobody@fake.address9z.com">Mr Nobody</a>[/code] Needs to be recoded as: [code]<script>mail2("nobody","fake.address9z",0,"","Mr Nobody")</script>[/code] The simplest way to encode your mail links is to use this automatic tool. This converts a list of email addresses into the required javascript calls for step (2), with a simple button press. If you do want to encode the links manually, here is a description of the five parameters needed by the mail2() function call: 1. The email name: i.e. the bit before the @ sign 2. The second-level domain of the email address: this is the bit after the @ sign, but with the top level domain (\".com\" or \".co.uk\" etc) stripped off. 3. A number specifying which top-level domain to use. I list these below. 4. The fourth parameter allows you to specify a default subject for the email, by passing e.g. \"?subject=Changeringing\", but normally you\'ll just need the empty string \"\". 5. Finally, the text of the link, i.e. the name to be displayed to the user in the web page. Sometimes you might want to code a link in which the email address itself is shown as the visible text, e.g. nobody@fake.address9z.com. To do this, simply call mail() rather than mail2(). Only the first four parameters are needed. Numbers for top-level domains The use of numbers helps hide the email address from spam harvesters. My email.js file uses the following table of common top-level domains: 0 .com 1 .org 2 .net 3 .ws 4 .info 10 .co.uk 11 .org.uk 12 .gov.uk If you have a need for other top-level domains, these can easily be added to the tld_[] array declared at the start of the email.js file. Alternatively, you can pass a \"-1\" value to the mail() and mail2() calls, and simply leave the unknown top-level domain on the end of parameter 2. This is slightly less secure but should still be safe from most harvesters. However, the best solution is to use the automatic encoder, which uses a -2 parameter to pass an encrypted version of the complete domain name; this is the most secure option. Browser Compatibility The code in email.js is valid javascript 1.1 / ECMA-262, and as such will run correctly in all modern browsers including Internet Explorer from version 4, Netscape Navigator from version 4, Mozilla and Opera. A very small number of users may have scripting disabled. For them it may be worth adding a note that the email addresses will not be visible. You can do this with HTML code such as: [code]<noscript><p> Please note that email addresses on this site are protected to avoid abuse by spammers. You will need a javascript-enabled browser to see the email addresses. </noscript>[/code] Advantages and Disadvantages javascript - Adding an email address builds trust with your visitors because when they click your email link, their mail browser opens and they know that when when they send that eMail, it is going directly to you. Contact Form - With a contact form, you are sending valuable Page Rank to yet another page on your site. From that page, you can send more Page Rank to still other pages. Note to Content Management Software Developers Some article submission services publish authors articles along with the email address of the author. In this day and age, this is unacceptable. I would call this version \"the barely ready beta version\". In other words, it is ready for BETA release after this problem is fixed. If you develop Article Publishing software, and the published articles include the authors eMail address, you are on a losing streak. I have spoken to owners of this type of software and they are on the lookout for something better. This applies to other types of software scripts which publish HTML with an eMail address. Not everybody wants to open up free eMail dumping accounts. About the Author: The author, Ed Zivkovic is a self taught webmaster. His website contains articles with all sorts of tips for work at home webmasters. Here is the site: [url=\"http://www.ezau.com\"]http://www.ezau.com[/url] Sources: [url=\"http://www.bronze-age.com/nospam/index.html\"][u]Bronze Age no-spam[/u][/url] [url=\"http://www.devwebpro.com/\"][u]DevWebPro[/u][/url]
Image

[color=\"#41211C\"]It takes years to build up trust and only seconds to destroy it

[/color]
Josh
Hero Member
Hero Member
Posts: 4627
Joined: Fri Jun 04, 2004 2:54 pm

JavaScript To Hide Your EMail From Spambots

Post by Josh »

I like this concept /smile.gif\' class=\'bbc_emoticon\' alt=\':)\' /> Good find Adaera! /biggrin.gif\' class=\'bbc_emoticon\' alt=\':D\' />
[align=center]

Image

“If you stop learning, you stop living.” ~Tami Quiring

“It's the rare man who understands the value of a single perfect rose.”

[/align]
Post Reply

Return to “Web Design Principles”