: Email obfuscated in HTML page I am trying to design a page based on simple material design lite - similar to this page: http://fxpblog.co/firefox/nightly/. If you look in line 380 of source
I am trying to design a page based on simple material design lite - similar to this page: fxpblog.co/firefox/nightly/.
If you look in line 380 of source code the email address is given but it is obfuscated. Whenever I try the same I just copy and paste the whole section it does not work for me.
My template page looks like this: codepen.io/anon/pen/qNybqN.
More posts by @Candy875
2 Comments
Sorted by latest first Latest Oldest Best
This is not what i would call obfuscation - that is just encoding of entities. If you really want to obfuscate the email address use something like this:
<script>
function hide(id) {
document.location = id.replace(/|/g, '');
}
</script>
<button class="btn btn-default" data-to="mailto:john@|doe|.|org" onclick="document.location=this.dataset.to.replace(/|/g, '')">
E-Mail
</button>
Look at jsbin.com/takesixazu/edit?html,js,output, how it works: you divide the string you want to obfuscate, and then put it together through user action.
That text (value of the anchors href attribute) is simply HTML entity encoded. (Although I'm not convinced how effective that would be today to prevent the email being harvested.)
Should I encode it first and put it in the source?
Yes, you need to encode it first - it doesn't get automatically encoded (unless you are using some kind of framework/CMS that does this for you). Most server-side languages have functions built-in for HTML encoding/decoding.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.