| Tired of web spiders finding your email address from the pages on your site?, this may help. It's quite common to insert a "mailto" link on your pages to make it easy for people to send you an email. This is usually done by simply placing code like this |
| <a href="mailto:fred@frednerk.com">email me</a> |
|
in the body of your page. The problem with this is that web spiders are constantly on the lookout for email addresses for spam lists. They read your pages looking for the pattern x@y.com and extract the address. Next thing you know your on another spam list. Now we're not allowed to shoot spammers, and anyway you can't find the bastards, but you can go some of the way to stopping the spiders from finding your addresses in you web pages by inserting email addresses with Javascript code rather than as plain text. The simplest way I know to do this is embed
the code directly where you want the link. |
| blah blah blah please <script> document.write ("<a href=\"mailto:"+"fred"+"@"+"nerk."+"com"+"?subject=some subject\" >email me </a>")</script> for more information |
| This will place the link on your page as follows
blah blah blah please for more information Note that the email address is broken up into separate strings which are then concatenated. This should stop any non-human from realising what is going on. If you have several mailto links on a page it's better
to create a function that does most of the work and place calls to the
function in your text. Put this code in the <head> section of
your page. |
| <script language="Javascript"> function noSpamMailto (s) { var x = "fred" var y = "frednerk" var z = "com" var xyz = x+"@"+y+"."+z if (s != "") subject = "?subject="+s else subject = "" document.write ('<a href="mailto:'+xyz+subject+'">'+xyz+'</a>') } </script> |
Then insert this code in the body of the
page where you want the mailto links. |
| blah blah blah <script>noSpamMailto("subject
1")</script><br> blah blah blah <script>noSpamMailto("subject 2")</script><br> blah blah blah <script>noSpamMailto("subject 3")</script><br> |
|
To produce something like this (Note that the <br> stands for "break" and is simply a carriage return). blah blah blah
In this example the email address is used as
the link text which may not be appropriate. To make the function print
something different for each link we have to modify it and add a second
parameter. |
| <Script language="Javascript"> function noSpamMailto (s, text) { var x = "fred" var y = "frednerk" var z = "com" var xyz = x+"@"+y+"."+z if (s != "") subject = "?subject="+s else subject = "no subject" document.write ('<a href="mailto:'+xyz+subject+'">'+text+'</a>') } </script> |
Then insert code like this in the body of
the page where you want the mailto links. |
| blah blah blah <script>noSpamMailto("subject
1", "text 1")</script><br> blah blah blah <script>noSpamMailto("subject 2", "text 2")</script><br> blah blah blah <script>noSpamMailto("subject 3", "text 3")</script><br> |
|
Now we get something like this blah blah blah
Note that this time the second parameter is used as the link text. Naturally there are a thousand variations on
this theme but this should get you get you going. |
![]() |