What's the best method out of these three to hide an email address yet still have it function but still display the correct email address to the user and have it function as a mailto: link when clicked on? (Using Wordpress site in this case)
2A. USING THE ‘ONCLICK’ EVENT
You can create a regular mailto hyperlink for your email address but replace some of the characters – like the dot and the @ sign – with text. Then add an onclick event to this hyperlink that will substitute the text with the actual symbols.
<a href = "mailto:johnATgmailDOTcom"
onclick = "this.href=this.href
2B. RANDOM ARRAY
- WORDPRESS + PHP
If you are on WordPress, you can also consider using the built-in antispambot() function to encode your email address. The function will encode the characters in your address to their HTML character entity (the letter a becomes
a and the @ symbol becomes
@) though they will render correctly in the browser.
<?php echo antispambot("email@example.com"); ?>