Check out this email cloaking page for an example.
This is the HTML...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
<html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Untitled Document</title> <script type="text/javascript"> function emailCloak() { if (document.getElementById) { var alltags = document.all? document.all : document.getElementsByTagName("*"); for (i=0; i < alltags.length; i++) { if (alltags[i].className == "emailCloak") { var oldText = alltags[i].firstChild; var emailAddress = alltags[i].firstChild.nodeValue; var user = emailAddress.substring(0, emailAddress.indexOf("(")); var website = emailAddress.substring(emailAddress.indexOf(")")+1, emailAddress.length); var newText = user+"@"+website; var a = document.createElement("a"); a.href = "mailto:"+newText; var address = document.createTextNode(newText); a.appendChild(address); alltags[i].replaceChild(a,oldText); } } } } window.onload = emailCloak; </script> </head> <body> <span class="emailCloak">chris(at)testcloak.com</span> </body> </html> |
Thanks to dkram for the snippet (http://snippets.dzone.com/posts/show/1985)