E-mail Address Encoding

This page describes one option available for displaying e-mail addresses on web pages so that simple text searches of the HTML encoding will not locate "mail to" tags and their contents.  The purpose of this is to reduce the incidence of unwanted collection of e-mail addresses for bulk sale to senders of junk-mail.

Similar arrangements can be adopted should it be desirable to protect URL (Uniform Resource Locators) or telephone numbers in the same way.


JavaScript Fragments

The encoding uses an external JavaScript file to contain the e-mail address (or URL or phone number), in each encoded using ASCII character codes.  This removes these details from the content of the HTML file.  JavaScript is used to assemble the address string and display it at the appropriate point of the page concerned.

Additional text and/or formatting tags can be included in the JavaScript file if convenient.

It is particularly convenient to use this approach if the content is repeated on several pages.  If the address or number is changed, only the JavaScript file needs to be updated.

Fragment 1:  The character codes making up the desired e-mail address are listed in the variable "email_1a".  The variable "email_1b" is next made to hold the corresponding string of characters for display on the page.  Finally, the string within "email_1b" is assembled into the desired context for displaying the address on the HTML page.  As shown here, it will often be included twice; once as part of the "mailto:" parameter and then between the "<a>" and "</a>" tags, where it is normally visible on the page.

Similar coding is applicable to URL representation.

     var email_1a = [106,111,104,110,50,55,64,116,101,110,50,55,46,111,114,103] ,
         email_1b = '' ;
         ( var i=0; i<email_1a.length; i++ )
           email_1b += String.fromCharCode (email_1a[i]) ;
     var email_1c = 'e-mail to:
                    href="mailto:' + email_1b + '"
                    + email_1b +
                    <br />

Fragment 2:  For phone numbers, there is no equivalent of the "mailto:" tag, but otherwise the coding follows the same principle as used above.

     var phone_1a = [48,55,53,50,56,32,55,57,48,56,48,53] ,
         phone_1b = '' ;
         ( var i=0; i<phone_1a.length; i++)
           phone_1b += String.fromCharCode(phone_1a[i]) ;
     var phone_1d = '<span class="phone">'
                    + phone_1b +
                    <br />

Fragment 3:  Fragments 1 and 2 are included in a .js script file.  To call for the content within a web page, that page requires a simple "with (document) {write()};" call, such as the following:

     <script language="JavaScript" type="text/javascript"><!--
     with (document) {write(' - phone number '+phone_1b+' - '+email_1c)};

Legal Characters for Addresses & Numbers

The list below contains legal ASCII Character Codes for e-mail addresses, URL and telephone numbers.


Look-up table for alphanumeric characters

08-a613  Top of
this page

John Goodman