Wiz's Template Design Course for eBay Sellers

E-Mail Links

Sometimes you want to use a link that invokes the viewer's e-mail program so they can send you e-mail. A simple e-mail link is done like this:

<a href="mailto:steve@ourhutch.com">send e-mail</a>

Notice that the URL portion is:

mailto:steve@ourhutch.com

The protocol portion has been changed from the usual http: to mailto: -- this is what invokes the viewer's e-mail program. This protocol portion of the URL is followed by the e-mail address you wish the e-mail sent to.

What if you want the subject line to be automatically filled in? In that case you send the subject contents along with the URL as appended data, like this:

<a href="mailto:steve@ourhutch.com?subject=question about HTML">send e-mail</a>

Notice the question mark (?) that separates the active part of the URL from the appended data. This format will fill in the e-mail subject field with: question about HTML and is useful when the sender doesn't put something meaningful in the subject.

In the same manner, you can pre-fill the body of the message too:

<a href="mailto:steve@ourhutch.com?subject=question about HTML&body=This is the text that will appear in the body of the message.">send e-mail</a>

Notice again the question mark (?) that separates the data from the active part of the URL but now also notice that the two parts of the data (the subject and the body) are separated from each other by an ampersand (&).

Beware Spammers!

There is a problem with using an e-mail link in your web document or eBay auction listing. Your e-mail address can be harvested by spammers and you will find yourself receiving a lot of unwanted e-mail. There is something you can do about this, however. Using a simple JavaScript construction you can mask your e-mail address from these automated harvesters. Real people who know what they are doing can look at the code and figure out your address but you won't find many people doing this for spamming purposes.

Here is the script to use. Just put it directly in place of your e-mail address, both in the link and anywhere you display it as text. Substitute the part of your e-mail address to the left of the @ sign for yourname and the part to the left of the @ sign for yourdomain

<script language="JavaScript">
var name="yourname";
var domain="yourdomain";
var text='<a href="mailto:'+name+'@'+domain+'">';
text+='Send E-Mail</a>';
document.write(text);
</script>

You might want a version that includes auto-filling the subject with the listing title and number:

<script language="JavaScript">
var name="yourname";
var domain="yourdomain";
var subject=escape(document.title);
var text='<a href="mailto:'+name+'@'+domain+'?subject='+subject+'">';
text+='Send E-Mail</a>';
document.write(text);
</script>

Note: the above script is styled after a version offered by 'concho_softie', one of the eBay Photo/HTML board regulars who is well versed in JavaScript.
 

It's always the right time to use good code!

[ back | top ]

design by wizard_mithrandir
Copyright © 2002, 2008, by Stephen B. Henry