web blazonry web development scripts and tutorials
 
Web blazonry.com
   Home       PHP       Name Generators       Perl       CSS       Javascript       Java       devTips       Resources   

Javascript Home


image scripts
  Image Load Order
  Mouse Overs
  SlideShow

JavaScript Resources
  Free JavaScript Books(new)
  Recommended Sites
  Bestselling Books





JavaScript : Hiding Email Addresses

Also known as “Fooling SpamBots”, this JavaScript code example makes it difficult for SpamBots to automatically obtain email addresses when they scan your web pages. The JavaScript function “breaks” your email address into components and “re-assembles” the components for display on the page.

As a result, there is nowhere in your source code that provides a full, intact email address that can be easily parsed from your file. Anything one can do to fool spammers is a good thing I say.

Here's the code for the function:

<SCRIPT LANGUAGE="JavaScript">
<!--

var lhs = "web";
var rhs = "blazonry.com";

function print_mail_to_link()
{
   document.write("<a href=\"mailto");
   document.write(":" + lhs + "@");
   document.write(rhs + "\">" + lhs + "@" + rhs + "<\/a>");
}

//-->
</SCRIPT>

Here's the code to call the function:

This code goes where you want your “mailto” address to appear on the page.

<script language="JavaScript" type="text/javascript">
   print_mail_to_link()
</SCRIPT>

A normal-looking email address link appears on your page and looks like:


But nowhere in your HTML is there an email address that is intact and deciperable by SpamBots. (grin)

Of course, you can modify the function to display the email address not as a link but as plain old non-linkable text.

 

Newest Pages
Free Linux Admin Books
Free Linux Books for Programmers
Free Books for Linux on the Desktop
Free PHP Books
Free JavaScript Books
Free Java Books - Advanced
Free Java Books - Basic
Free Perl Books
Free Python Books
Quote of the Day (PHP)
Debugging Part 2
How to Test Google Ads
Source Code for Test Google Ads (PHP)
Most Popular Pages
U.S. Name Generator
Wu Name Generator
Baby Name Generator
Upload and Resize an Image (PHP)
Popup Windows (JavaScript)
How To Install Apache + PHP + MySQL
Simple Web Calendar (PHP)

Least Popular Pages
Image Load-Order (Javascript)
dHTML: Scrolling Layers
iNews Aplet (Java)
ProcLog Search Your Logs (Perl)
 
 

  © 1997-2007. astonishinc.com   All Rights Reserved.