Feed on
Posts
Comments

Using JavaScript to prevent email addresses harvesting by spammers if an effective method against the standard harvesting programs. Nevertheless the spammers could modify their harvesting programs to read the email addresses from the JavaScript. That is why this is not a bulletproof solution but is really effective and could easily be customized for any web site.
 
The idea is to create a JavaScript function that will print the email address:

function printEmail(theName, theExtras, theLink, theDomain) {

var theEmail = theName + "@" + theDomain;

    if (theName == "") {
        theName = "ERROR";
        theLink = "ERROR";
        myEmail = theName;
        myLink = theLink;
       
    } else {
   
        if ((theExtras == "") && (theLink =="")){
            myEmail = theEmail;
            myLink = theEmail;
        }
       
        if ((theLink == "") && (theExtras != "")){
            myLink = theEmail;
            myEmail = theEmail+theExtras;
        }
       
        if ((theLink != "") && (theExtras != "")){
            myLink = theLink;
            myEmail = theEmail+theExtras;
        }
       
        if ((theLink != "") && (theExtras == "")){
            myLink = theLink;
            myEmail = theEmail;
        }
    }
   
    document.write(’<a href="mailto:’ + myEmail + ‘" class="email">’ + myLink + ‘</a>’);
}

You can call the function using this line of code:

<script type="text/javascript">printEmail("ivan", "", "", "gmail.com");</script>

,
Share and Enjoy: These icons link to social bookmarking sites where readers can share and discover new web pages.
  • del.icio.us
  • dzone
  • Netscape
  • digg
  • YahooMyWeb
  • Technorati

Trackback URI | Comments RSS

Leave a Reply

This is a captcha-picture. It is used to prevent mass-access by robots. (see: www.captcha.net)

You must read and type the 5 chars within 0..9 and A..F, and submit the form.

  

Oh no, I cannot read this. Please, generate a