[WEB4LIB] RE: re webmaster address on web site

Chris Gray cpgray at library.uwaterloo.ca
Fri Aug 9 09:49:28 EDT 2002


You can also prevent email address harvesting with a JavaScript.  The
email link appears as normal in a browser, but the page source can't
easily be parsed to harvest an email address automatically.

We use the following script in the head of a document:

<script>
function writeEmail(username,domain,displayText) {
document.write( '<a href=\"mailto:' + username + '@' + domain + '\">' + displayText + '</a>' );
}
</script>

And then replace anything like

    <a href="mailto:nobody at www.bogus.com">the Webmaster</a>

with

    <script>writeEmail('nobody','www.bogus.com','the Webmaster');</script> 

You can then put other people's contact info on your page without
subjecting them to increased spam.

Chris Gray
Systems Analyst
University of Waterloo




More information about the Web4lib mailing list