Hiding an Email Address from Spammers

A constant source of irritation is spammers who use web crawling software to grab your email address off web pages, to which spam is then sent. One way to try to defeat this is to hide your email address from such software, but still make it visible to a human. There are several ways of doing this, but the trick used here is to hide it in an external JavaScript file, which writes the email address to a location in the page that you specify. Accordingly, place something like:
<div id='mail'></div>
or use another HTML tag with that id, or another one of your choice, in your HTML code. Next, you write an external file with the following contents:
function myEmail() { var username = [username]; var domain = [domain]; var linkText = username + '@' + domain; document.getElementById('mail').innerHTML = 'Email address: <a href="mailto:' + linkText + '">' + linkText + '</a>'; }
where the quantities in square brackets are replaced by strings in quotes containing your real user name and domain, such as 'gmail.com'. By calling this function on loading your HTML page, your clickable email address will be shown between the opening and closing div tags with the 'mail' id, or whatever other HTML tag you use with an id of your choice. In looking at the browser's source, nothing is visible, so any web crawling software should find nothing. The message in front of the <a href=...> tag can be anything, or it can be left blank, and any such message can be placed in the regular HTML code.