Carnegie Mellon University Website Home Page
 

The "mailto:" Tag

Spam Robots or Spiders "crawl" the Internet searching for "mailto:" tags. To create a clickable "mailto:" hyperlink that is spam resistant, use the following JavaScript on your web pages.

<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
user = "myusername";
site = "myhost.com";
document.write('<a href=\"mailto:' + user + '@' + site + '\">');
document.write('Email me!' + '</a>');
// End -->
</SCRIPT>

This will result in a "mailto:" like this: Email me!

Steps to create a clickable "mailto:" hyperlink:

  1. Copy and insert the above JavaScript into your html source code at the mailto: insertion point.
    Note: Some html authoring tools may require you to use an automated tool for inserting the JavaScript (e.g., Insert > Script Object in Dreamweaver).
  2. Edit the script to include the user name and mail host.

    For example, suppose email should be sent to jdoe@andrew.cmu.edu. Within the script, the lines that read:
    user = "myusername";
    site = "myhost.com";

    must be changed to:
    user = "jdoe";
    site = "andrew.cmu.edu";
  3. Save your html file. The JavaScript will generate a clickable link that reads "Email me!".

Last Updated: 7/13/04