Reply to comment

Email Cloaking Script (Email Hiding)

Originally from: 2007-09-26 15:17:44 -0700

Here's a perl script that takes email addresses as arguments, and returns javascript code that hides your email address from web spiders. The email address is also linked so it's clickable.

#! /usr/bin/perl

foreach my $email (@ARGV) {

        $email =~ s/@/ @ /;
        $email =~ s/\./ . /;

        @parts = split( ' ', $email );

        print "<script type='text/javascript'>\n";
        print "document.write('<a href=\"mailto:');\n";
        foreach my $word (@parts) {
                print "document.write('".$word."');\n";
        print "document.write('\">');";
        foreach my $word (@parts) {
                print "document.write('".$word."');\n";
        print "document.write('</a>');\n";
        print "</script>\n\n";

Update: Here's another technique. I don't know how reliable this is, but it's simpler than the above. Javascript has two functions, window.btoa() and window.atob() that encode and decode base64. You can simply encode the HTML for your email link, and then paste that into a short Javascript one-liner to decode it to the page.

To encode, type this into the debugger or Javascript Console:

window.btoa('<a href=""></a>');

The output is:


Next, in your web page, wrap this code around the encoded string:



The content of this field is kept private and will not be shown publicly.
  • Lines and paragraphs break automatically.

More information about formatting options

6 + 7 =
Solve this simple math problem and enter the result. E.g. for 1+3, enter 4.