Javascript to hide email addresses from crawlers (and spammers)

There are of course many ways to do this… One way is to always use an image to display the email address, so a user has to manually type it into their email client. An easy way to hide email addresses, while still using a mailto: link, is to use a simple javascript function.

Here’s the one I use:

<SCRIPT TYPE=”text/javascript”>
<!–
// protected email script by Joe Maller
// JavaScripts available at http://www.joemaller.com
// this script is free to use and distribute
// but please credit me and/or link to my site

emailE=(’name@’ + ‘domain.com’)
document.write(’<A href=”mailto:’ + emailE + ‘”>’ + emailE + ‘</a>’)

//–>
</script>

Instructions for use:

If you’ve already set up a mailto: link, you should have something that looks like this in your HTML code:

<a href=”mailto:name@domain.com”>name@domain.com</a>

Simply replace that entire tag with the script above, and then change the variables in “emailE.” It won’t show up in Dreamweaver, but when you test it out on the server, the email address will be there… for human eyes only…

RELATED / YOU MIGHT FIND THESE INTERESTING




Like this story? Share with others on:
   del.icio.us    digg    reddit    furl      Stumble it!


COMMENTS / 2 COMMENTS

Hi,
I am using
http://www.mobilefish.com/services/hideemail/hideemail.php to protect my email address against spam bots.
This site also contains other useful tools.

Jack added these pithy words on Aug 16 08 at 8:30 am

Hi,

Thanks for this, its easy to use yet effective to work.

Synergy Informatics added these pithy words on Oct 07 08 at 5:37 am

SPEAK / ADD YOUR COMMENT
Comments are moderated.

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <code> <em> <i> <strike> <strong>

Return to Top

Technorati Tags: