2008年11月30日日曜日

Brief codes to show your Email Address on the web

If you want to provide your email address as a contact infomation to the visitors to your web site but you don't want to provide it to the crawler (because they send you many spam mails), please copy and paste the JavaScript code like below into your html.
<script type="text/javascript">
//<![CDATA[
window.onload = function () {
// Start creating a mail address
var m = 'info';
m += '@';
m += 'ciri.us';
// Insert mail address to your document
document.getElementById('mailto').innerHTML = m;
document.getElementById('mailto').href = 'mail' + 'to:' + m;
};
//]]>
</script>
The example html code is like below.
You should use alink tag and provide it DOM id as "mailto" where you want to insert your mail address.
<p>
Our new web site will be online in early 2009. Stay tuned for updates.<br/>
In the meantime, please visit the <a href="http://www.ciri.us/">Cirius Technologies</a> corporate web site. <br />
Or, contact us at <a id="mailto" href=""></a>
</p>