• Quick note - the problem with Youtube videos not embedding on the forum appears to have been fixed, thanks to ZiprHead. If you do still see problems let me know.

Linking to Emails using Javascript

YoPopa

Graduate Poster
Joined
Jun 6, 2005
Messages
1,484
I must display a large number of Email address links on my pages. Spambots are the bane of my existence. Are the Javascripts which hide the address really effective against the Spambots or have the spammers caught up with this trick?

Does anyone have a favorite Javascript for this purpose, preferably one that includes a subject line for the Email?

An example of what I am talking about at: http://joemaller.com/js-mailer.shtml
the example above does not include the subject or I would be using it.

yo :yo-yo:
 
I don't know if it's effective at fooling spambots, but this should work. I just copied it from your link, and added a subject.
Code:
<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='somewhere.com?subject=something'
emailE=('somebody' + '@' + emailE)
document.write('<A href="mailto:' + emailE + '">' + emailE + '</a>')

 //-->
</script>

<NOSCRIPT>
    <em>Email address protected by JavaScript.<BR>
    Please enable JavaScript to contact me.</em>
</NOSCRIPT>
It will create a link that sends mail to somebody@somewhere.com with a subject of "something".

Is this the sort of thing you wanted?

The line starting with "document.write" contains the word "emailE" twice. The first one has to be there for the thing to work. The second one is where you put what you want the link to look like on the web page. If you leave it the way it is, the link will look like this:

somebody@somewhere.com?subject=something

You can put whatever you want there, instead of the word "emailE", but put it between single quotes, like this:
Code:
document.write('<A href="mailto:' + emailE + '">' + 'something else' + '</a>')
(But don't type the email address there explicitly, because that would just defeat the purpose of the whole thing.)
 
Last edited:
Is this the sort of thing you wanted?
That's great, it's in the yo! Thank you very much. The only thing that might make it better would be if I did not have to remember every single quote mark. ;)

I have set up a new Email address and placed the code on some pages where it should get a few hundred views/day. If it attracts spam at the same rate as other addresses that I have used then I should know fairly soon.

Yo :yo-yo:
 

Back
Top Bottom