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 = '' ;
for
( var i=0; i<email_1a.length; i++ )
email_1b += String.fromCharCode (email_1a[i]) ;
var email_1c = 'e-mail to:
<a
href="mailto:' + email_1b + '"
class="mail"
>'
+ email_1b +
'</a>
<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 = '' ;
for
( var i=0; i<phone_1a.length; i++)
phone_1b += String.fromCharCode(phone_1a[i]) ;
var phone_1d = '<span class="phone">'
+ phone_1b +
'</span>
<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)};
//--></script>
Legal Characters for Addresses & Numbers
The list below contains legal ASCII Character Codes for e-mail addresses, URL and telephone numbers.
- 40 = ( (telephone only)
- 41 = ) (telephone only)
- 43 = + (telephone only)
- 45 = -
- 46 = . (e-mail & URL only)
- 47 = / (URL only)
- 48 to 57 = 0 - 9
- 58 = : (URL only)
- 64 = @ (e-mail addresses only)
- 65 to 77 = A - M (e-mail & URL only)
- 78 to 90 = N - Z (e-mail & URL only)
- 95 = _ (e-mail & URL only)
- 97 to 109 = a - m (e-mail & URL only)
- 110 to 122 = n - z (e-mail & URL only)
Look-up table for alphanumeric characters
| Character | A | B | C | D | E | F | G | H | I | J | K | L | M | |
| Code | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | |
| |
|
| Character | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | |
| Code | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | |
| |
|
| Character | a | b | c | d | e | f | g | h | i | j | k | l | m | |
| Code | 97 | 98 | 99 | 100 | 101 | 102 | 103 | 104 | 105 | 106 | 107 | 108 | 109 | |
| |
| |
| Character | n | o | p | q | r | s | t | u | v | w | x | y | z | |
| Code | 110 | 111 | 112 | 113 | 114 | 115 | 116 | 117 | 118 | 119 | 120 | 121 | 122 | |
| |
| |
| Character | 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | |
| Code | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | |