Mailto is just a pseudo protocol that is used instead of http.
At any rate, maybe something like the following code will help. Even better if the javascript is in an external file, then a bot is less likely to grab the code with the email.
I put together a quick and dirty rot13 (rot 10 for numbers) like script for the
munging. But, feel free to replace the call with what ever function you are using. The javascript simply takes the contents of the div and moves them to the new anchor tag, the anchor tag is then added as a child to the div.
The CSS is the same as before (only adding props to the div as well).
HTML Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Untitled Document</title>
<style type="text/css">
div#contactLink, a.contact {
display: block;
width: 100%;
text-align: center;
text-decoration: underline;
}
a.contact:link{
color: #7F7F7F;
}
a.contact:visited{
color: #7F7F7F;
}
a.contact:hover{
color: #00CCFF;
background-color: #7F7F7F;
}
</style>
<script type="text/javascript">//<![CDATA[
var HalfRot = {
lookUp : null,
init : function(){
var upper = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
var lower = "abcdefghijklmnopqrstuvwxyz";
var nums = "0123456789";
this.lookUp = new Array();
this.lookupPop(upper);
this.lookupPop(lower);
this.lookupPop(nums);
},
lookupPop : function(srcStr) {
var half = srcStr.length/2;
for(var i=0;i<srcStr.length;i++){
var fix = (i<half)?1:(-1);
this.lookUp[srcStr.charAt(i)] = srcStr.charAt(i+(half*fix));
}
},
rot : function(strIn){
var out = "";
for(var i=0;i<strIn.length;i++){
var val = this.lookUp[strIn.charAt(i)];
if(val){
out += val;
}else{
out += strIn.charAt(i);
}
}
return out;
}
};
HalfRot.init();
function activateContactLink(){
var wrapper = document.getElementById("contactLink");
var mailLink = document.createElement("a");
mailLink.href = "mailto:" + HalfRot.rot("cnhy.qnivf@jvyypbqr9orre.pbz");
mailLink.className = "contact";
var children = wrapper.childNodes;
for(var i=0; i<children.length;i++){
mailLink.appendChild(children[i]);
}
wrapper.appendChild(mailLink);
}
window.onload = activateContactLink;
//]]></script>
</head>
<body>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Etiam blandit augue in tortor. Phasellus sem sapien, faucibus non, mattis in, venenatis non, orci. Quisque euismod molestie ante. Curabitur eu nisl id nulla sagittis pharetra. Vivamus cursus ligula non quam. Proin ante. Nunc accumsan nibh ut diam. Suspendisse faucibus, justo sit amet dignissim pharetra, eros quam aliquam mauris, a lobortis dui odio vitae leo.
</p>
<div id="contactLink">Contact Me</div>
</body>
</html>
BTW, the rot is reversible, so, if you want to make a string to put in your script, just call it with the plain text.
For example:
HTML Code:
var torot = "paul.davis@willcode4beer.com"
prompt(torot,HalfRot.rot(torot));
then you could copy the value out and paste it in your script.
HTH