Tuesday, October 30, 2007

Encoding email addresses in HTML pages

A while ago I noticed that GROX use URL encoding to put their e-mail address
in a "mailto" link. I guess they do this in order to make it more difficult for address harvesters to pick up their e-mail.

In order to do the same for my wife's web site at http://pilatesinsightstudio.com I found the following couple of tricks:
  1. The "mailto" link is encoded using:
    perl -e 'use URI::Escape; print uri_escape("the@email.address", "\0-\377"), "\n";'
  2. The title of the link, which I wanted to contain the e-mail address in HTML, was created simply by using the HTML Encoder from CodeHouse

No comments: