Komplet løsning med kryptering, forhindring af automatisk aktivering eller kopiering:
<!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>JavaScript Email-Mask</title>
<script type="text/javascript" src="
jquery-1.7.2.js"></script>
<style type="text/css" media="screen">
#Wrapper
{
width: 971px;
margin: 0 auto;
font-family: Verdana;
}
</style>
</head>
<body>
<div id="Wrapper">
<a href="mailto:blabla@hotmail.com" class="EmailLink">blabla@hotmail.com</a><br />
<a href="mailto:blabla@hotmail.com" class="EmailLink">dgdsfgds@hotmail.com</a>
</div>
<script type="text/javascript">
var intEmailMaskShift = 1;
$(document).ready(function ()
{
$("#btn_MaskEmail").click(function () { maskEmail(); });
$("#btn_UnmaskEmail").click(function () { unmaskEmail(); });
$(".EmailLink").each(function () { maskEmail(this); });
});
function maskEmail(target)
{
var strEmail = $(target).attr("href");
var strMaskedEmail = "";
for (var i = 0; i < strEmail.length; i++)
{
strMaskedEmail += String.fromCharCode(strEmail.charCodeAt(i) + intEmailMaskShift);
}
$(target).attr("href", "java script:void(0)");
$(target).html($(target).html().replace("@", "<span style=\"font-size: 0;\">(fjern paranteser og indhold)</span>@<span style=\"font-size: 0;\">(fjern paranteser og indhold)</span>"));
$(target).mouseup(function () { unmaskEmail(strMaskedEmail); });
}
function unmaskEmail(email)
{
var strUnmaskedEmail = "";
for (var i = 0; i < email.length; i++)
{
strUnmaskedEmail += String.fromCharCode(email.charCodeAt(i) + intEmailMaskShift * (-1));
}
window.open(strUnmaskedEmail);
}
</script>
</body>
</html>