Pioneer Skin
Login  ::  Register
Saturday, May 19, 2012
 
- - - - - - - - Sponsorship Advertisement Area - - - - Thank you to our Sponsors - - - - - - - - -
New Horizons Computer Learning Centers

We are please to introduce the new and improved discussion forum. It should eliminate the issues we've been having with the discusson board in the past. The old forum will still be available in "read only" mode HERE in case anyone wants to review the old topics that were posted.

WGD Forum: Discussion
Subject: protect email addresses with javascript
Prev Next
You are not authorized to post a reply.

Author Messages
terrydavidsonUser is Offline
Newbie
Newbie
Posts:6


10/29/2007 9:56 PM  
If you put any email addresses on your website for visitors to contact someone you need to protect the link from SPAM harvester programs. Spelling out the email address in the text or associating a valid email address with alternate text will surely be harvested and those email addresses will be added to SPAM lists. I have found that by using a very simple javascript code that has been circulating around the internet for years has worked wonderfully at providing valid links without the ability to be harvested.

Basically you define 3 variables, one for the actual text to be displayed on the webpage, one for the first part of the email address (before the @ symbol) and one variable for the domain name. The script is broken up into parts and between basic script commands and the variables it puts the link together.

Here is an example of what I like to use:

<script language=javascript>
<!--
var recipient = "Name to Display"
var email = "user_account"
var Host = "domain"
document.write("<a href=" + "mail" + "to:" + email + "@" + Host+ ">" + recipient + "</a>")
//-->
</script>

The document.write command with the variables will assemble the email address properly. You can change the name of your variables as long as you change them in the command string.

Just remember that it does use Javascript so if a person has javascript blocked or turned off within their browser it will not work. Currently the statistics say that 99.7% of users have javascript enabled within their browser, so it would be a small percentage.

Terry
magikmarcUser is Offline
Newbie
Newbie
Posts:29


10/30/2007 1:23 PM  
Good information Terry, and if you don't know JavaScript that well, here is another method to protect your email addresses on this site:
http://www.dynamicdrive.com/emailriddler/

I am using this on www.parishprojects.com right now, and it seems to be working pretty well.

Marc Coppins
www.NetMagikPros.com
hostUser is Offline
Newbie
Newbie
Posts:5


10/31/2007 2:23 PM  
Another way is to use flash and create a swf (ex create a link, a button, contact form etc) file and hide your email address that way.
tgoodsonUser is Offline
Newbie
Newbie
Posts:33


11/02/2007 12:21 AM  
Terry, bots are getting better at this sort of thing, and you need to move up a notch or two in the level of protection that you provide. The problem is that while simple bots read the source code for the page and look for email addresses, some the more complex ones actually parse the page (just like a browser) and then read the resulting page. Since your document.write inserts the address into the result page: BANG! they got ya.

Personally, I'd suggest moving to a form based email and assembling the address at the server (so it never sent to the user's / bot's browser) and using a capcha to avoid bots. The method that Marc uses seems to be very effective.
You are not authorized to post a reply.
Forums > Web Design > Programming > protect email addresses with javascript



ActiveForums 3.7
Home | Membership | Events | Forum | MyPage | Login
Copyright 2007-2008 by WGD Forum :: Designed by ZapWebDesign.com