View Full Version : hyperlink to java script

06-13-2003, 10:04 PM
I have been using java scripts to give email addresses on my website so that the email-collecting spiders can't see them.

I have a problem (I am a novice). I have a java script on my website at /java/online_email.js which reads:

var username = "dawson";
var hostname = "the-limes.com";
document.write("<a href=" + "mail" + "to:" + username +
"@" + hostname + ">" + "</a>")

On a test page I have an image which hyperlinks to "mailto:dawson@the-limes.com" using the html code:

<a href= "mailto:dawson@the-limes.com"><img border=0 src="http://opi.yahoo.com/online?u=simongoodhughdawson&m=g&t=2"></a>

QUESTION: How do I change the html code above to run the java script /java/online_email.js instead of the mailto:?

06-13-2003, 11:59 PM
<script src="java/online_email.js"><script><img border=0 src="http://opi.yahoo.com/online?u=simongoodhughdawson&m=g&t=2"></a>

NOTE: remove the </a> tag in the javascript

06-14-2003, 07:47 AM
Thanks for the help. It worked (once I had added an extra / before the second 'script'!).


06-14-2003, 09:37 AM
Unfortunately there's an accessibility problem there - because it's written in javascript, not everyone can see it.

My view is that you have to live with webmaster spam, by writing good rules and maybe having server-filters as well; live with it because, if you want to be universally contactable then you do have to expose your email address in literal plain text.

06-14-2003, 11:08 PM
brothercake, I can't vouch for this, but I have heard that bots will fail to "pick up" a mailto: link if it's written out with entities. So if we obfuscate the key characters the bot is looking for, like mailto: and @ and any dots... like so:

<a href="&amp;#109;&amp;#97;&amp;#105;&amp;#108;&amp;#116;&amp;#111;&amp;#58;webmaster&amp;#64;mydomain&amp;#46;com">

The link text will be translated into normal literal text when viewed inside all browsers, and the mailto: URL will be successfully translated by the e-mail client into a usable e-mail address, but I don't know if it actually prevents bots from grabbing the e-mail address.


Anyone have some experience with this technique? Or can vouch for it?

06-14-2003, 11:24 PM
or oyu could but your email addy in a picture like a jpeg or gif.

Or take after a guy in california who but i statement along with his unique email addy. It basically stated he would read any unsolicated email and recieve $500 and the company could be sueable.


06-14-2003, 11:52 PM
or oyu could but your email addy in a picture like a jpeg or gif.

Yeah, but that has implications for accessibility as well (people who don't have images turned on don't see the addy).

And also you would have to wrap the image in a link, and then you still face the original quandary regarding how to specify the mailto: without letting the bots pick it up.

06-15-2003, 10:46 AM
you wouldn't have to wrap it in a link, as the whole point is any legitimate people will read it and type it into there email client.


06-24-2003, 10:13 PM
yes but for surfers who don't have images ... you'd still need to put the real mail addy in the ALT attribute ..

06-24-2003, 10:28 PM
realisis, my understanding is that trick doesn't work, because most address harvesters rely on standard http and html libraries, and are capable of properly rendering character entities. don't hold me to that, though.

06-26-2003, 12:19 AM
but you see in the alt text you could have it in words as in @ would be at. Or you use a series of letter images in the alt text just put that letter in it, and place them in a row.

hmm that sounds looney.