GIDForums  

Go Back   GIDForums > Webmaster Forums > Web Design Forum
User Name
Password
Register FAQ Members List Calendar Search Today's Posts Mark Forums Read

 
 
Thread Tools Search this Thread Rate Thread
  #1  
Old 18-Jan-2004, 10:34
BobbyDouglas's Avatar
BobbyDouglas BobbyDouglas is offline
Regular Member
 
Join Date: Aug 2003
Posts: 789
BobbyDouglas has a spectacular aura aboutBobbyDouglas has a spectacular aura about

How to hide e-mail address from SPAM Bots [Javascript Tutorial]


Title says it all. I will demonstrate one of the better methods used to hide your e-mail address from the nasty eyes of SPAM Bots.

Our method of choice will be javascript!

Create a new file and name it gen_email.js.
Modify the file to fit the needs of your domain name.
Here is a sample script:
HTML Code:
<!-- function generate_address( username ) { var domain = "yourdomain.com"; var atsign = "@"; var addr = username + atsign + domain; document.write( "<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">" + addr + "<\/a>"); } //-->
Insert your domain name in the variable position of domain. You will replace youdomain.com with the domain you would like to use. This will be the second part of the e-mail address [something@yourdomain.com]
Save the file.
Insert the code to include the file in your page. Someplace between the <head> and </head> tags you will need to place the following code:
HTML Code:
<script src="scripts/gen_email.js" type="text/javascript"></script>

Of course, use the right folder for the script, I set mine up in a folder named scripts, this is where I include all of the scripts that I use.

Now that we have the basic script used to hide the e-mail address, next we will need to 'call' the function somewhere inside the page in order to display the e-mail address.

To do this, you will need to open the page that you want the e-mail address displayed on.

Goto the line you want the e-mail address displayed, and put this code on the line:
HTML Code:
<script language="javascript" type="text/javascript"> <!-- generate_address( "something" ); //--> </script>

This simple code will display the e-mail address: something@yourdomain.com. Of course, you will want to replace something with the beginning part of the e-mail address.

If you wanted to use support@yourdomain.com, you would then have something like this:
HTML Code:
<script language="javascript" type="text/javascript"> <!-- generate_address( "support" ); //--> </script>

Please post any problems or questions you have below. Enjoy!
__________________
Mr. Bob's Web Design - Tirelessly looking for ways to enhance the customer base of your business.
  #2  
Old 18-Jan-2004, 10:50
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
Good one... recently I have been coming to grips with JavaScript and it is my plan to have a collection of JS functions like these all stored in one global JS page. Another one you can work on is (if you find the time of course), one that manages external links easily - you know, the ones you don't want the Search Engine bots to follow
  #3  
Old 18-Jan-2004, 10:55
BobbyDouglas's Avatar
BobbyDouglas BobbyDouglas is offline
Regular Member
 
Join Date: Aug 2003
Posts: 789
BobbyDouglas has a spectacular aura aboutBobbyDouglas has a spectacular aura about
Quote:
Originally Posted by JdS
Good one... recently I have been coming to grips with JavaScript and it is my plan to have a collection of JS functions like these all stored in one global JS page. Another one you can work on is (if you find the time of course), one that manages external links easily - you know, the ones you don't want the Search Engine bots to follow

Explain some more about what you want. Maybe make a post about it in detail? How many more scirps until you will give us our very own javascript forum!?!?!?

Another thing, how come the tags do not work? I tried the same with but apparently those are not in here yet too.. Curious
__________________
Mr. Bob's Web Design - Tirelessly looking for ways to enhance the customer base of your business.
  #4  
Old 18-Jan-2004, 11:05
JdS's Avatar
JdS JdS is offline
Senior Member
 
Join Date: Aug 2001
Location: KUL, Malaysia
Posts: 3,371
JdS will become famous soon enough
The [JS] bbcode tags are not done ...yet, in the meantime you can use [code], or [html ] bbcodes if you prefer.

The function I am looking for is probably something like this:

HTML Code:
<a href="#" onclick="goto('www.example.com')">www.example.com</a>
  #5  
Old 18-Jan-2004, 11:30
cs2 cs2 is offline
Member
 
Join Date: May 2003
Location: California
Posts: 107
cs2 will become famous soon enough
There is a small error in your Javascript...
Quote:
Originally Posted by BobbyDouglas
"<" + "a" + " " + "href=" + "mail" + "to:" + addr + ">" + addr + "</a>");
It is not legal to have an unescaped closing tag inside double-quotes. You need to change the "</a>" to either:
"<\/a>"
-OR-
'</a>'
__________________
The Whole Internet, LLC
Visit our Homepage, -or-
use our online CSS Editor
  #6  
Old 22-Jan-2004, 02:53
conkermaniac conkermaniac is offline
Member
 
Join Date: Dec 2001
Location: China
Posts: 174
conkermaniac is on a distinguished road
Hi Bobby,

Thanks for the tip! Do you, by any chance, know how spam bots work? Couldn't they read the post-JavaScript text and collect that? Or do they simply scan through the HTML?

Conker
__________________
You're not supposed to be looking at this.
  #7  
Old 22-Jan-2004, 23:07
BobbyDouglas's Avatar
BobbyDouglas BobbyDouglas is offline
Regular Member
 
Join Date: Aug 2003
Posts: 789
BobbyDouglas has a spectacular aura aboutBobbyDouglas has a spectacular aura about
Do I know 100% for sure? No. My most logical guess would be that they read through the html file. They specifically search for the character @ or the ASCII for that character. Then they take the first part that is before the @ as the name, and the part after the @ as the domain.tld.

I am pretty sure that the bots do not search in javascript code if you include it outside of the source. Maybe there are some that do, but most wouldn't. But, we also take the precausion that they do, so we never display the e-mail address as one (soemthing@something.com). It is broken up, and then displayed on the page normally.
__________________
Mr. Bob's Web Design - Tirelessly looking for ways to enhance the customer base of your business.
  #8  
Old 11-Feb-2004, 22:28
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,335
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
I've written a code scrambler in JS and C. Check them out under utilities at http://wildeware.com. The JS can be used directly from the site, and 2 other versions (GUI and console mode) can be downloaded.

If you try them, let me know what you think.
  #9  
Old 28-Feb-2004, 17:19
Wintermute Wintermute is offline
New Member
 
Join Date: Feb 2004
Posts: 1
Wintermute is on a distinguished road
I was about to say something really stupid, but then I realised.. if you code the function in php you still have the same doubt as to whether the spambot can read the code or not, right? I suppose it depends how the spambot works..
  #10  
Old 28-Feb-2004, 22:19
WaltP's Avatar
WaltP WaltP is offline
Outstanding Member
 
Join Date: Feb 2004
Location: Midwest US
Posts: 3,335
WaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to allWaltP is a name known to all
Quote:
Originally Posted by Wintermute
I was about to say something really stupid, but then I realised.. if you code the function in php you still have the same doubt as to whether the spambot can read the code or not, right? I suppose it depends how the spambot works..
As long as the spambot cannot "reassemble" or "reverse" the encoding of the email address, you're good to go. In my solution above, there is no possible backtracking. In the code by BobbyDouglas, the backtracking would be just as impossible, as the pieces of the email are in two separate files.

By taking Bobby's code and converting it to PHP or even ASP, and putting that function in a separate file, you've accomplished the same end -- the email is split over your entire website.

A further encoding possibility is to make the '@' a value expression. The value for @ is hex 40. Make ATval = 20 and when you need the AtSign, add ATval to itself and convert to character. That way the bot has no @ nor hex 40 to find. This is probably overkill, but I doubt any bot would ever find the email address.
 
 

Recent GIDBlogOnce again, no time for hobbies by crystalattice

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump

Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The

All times are GMT -6. The time now is 13:17.


vBulletin, Copyright © 2000 - 2009, Jelsoft Enterprises Ltd.