As Sneeps pointed out very well, when the user clicks he will see the email.
But I believe your problem is not to expose your email to a page user, but to Bots that collect email for spam.
In this case you can confuse these bots by shuffling things up a bit. One way to do this is to transform the email into a base64 string, and for this we can use the following functions
var encodeBase64 = function (string) {
var bytes = string.split("").map(function (char) {
return char.charCodeAt(0);
});
return btoa(bytes);
}
var decodeBase64 = function (base64) {
var bytes = atob(base64).split(",").map(function (number) {
return parseInt(number);
});
return String.fromCharCode.apply(String, bytes)
}
Here is an example of the encode of your email:
var encodeBase64 = function (string) {
var bytes = string.split("").map(function (char) {
return char.charCodeAt(0);
});
return btoa(bytes);
}
document.getElementById("base64Prefixo").textContent = encodeBase64("mailto:");
document.getElementById("base64Email").textContent = encodeBase64("[email protected]");
<label id="base64Prefixo" ></label>
<label id="base64Email" ></label>
Now a second example with a link for sending the email, note that I put the base64 string we just got as a custom date.
var prefixo = "MTA5LDk3LDEwNSwxMDgsMTE2LDExMSw1OA=="
var inputsEmail = document.querySelectorAll("[data-email]");
var decodeBase64 = function (base64) {
var bytes = atob(base64).split(",").map(function (number) {
return parseInt(number);
});
return String.fromCharCode.apply(String, bytes)
}
var sendEmail = function (event) {
location.href = decodeBase64(prefixo) + decodeBase64(this.dataset.email);
}
inputsEmail = [].slice.apply(inputsEmail);
inputsEmail.forEach(function (inputEmail) {
inputEmail.addEventListener("click", sendEmail)
});
<a id="sendMail" href="#" data-email="MTE1LDExMSwxMDksMTAxLDExMSwxMTAsMTAxLDY0LDEwMSwxMjAsOTcsMTA5LDExMiwxMDgsMTAxLDQ2LDk5LDExMSwxMDk=" >Enviar Email</a>
13.08.2015 / 14:10