Here’s what you’d need to add instead of typing out an email address. On page load, the document.write command writes our email variable and small function, and outputs our email address. Since I’ve been using it, I’ve had no spam, even across client websites too.
var emailAddress = ('[email protected]' + 'yourdomain.com'); document.write('<a href="mailto:' + emailAddress + '">' + emailAddress + '</a>');
🎉 Download it free!
Ready to go beyond ForEach? Get confident with advanced methods - Reduce, Find, Filter, Every, Some and Map.
- 31 pages of deep-dive syntax, real-world examples, tips and tricks
- Write cleaner and better-structured programming logic within 3 hours
✅ Success! Check your email, enjoy.
As an extra bonus, we'll also send you some extra goodies across a few extra emails.
Type out the name without the @ symbol:
Use an image of your email address:
<noscript><img src="img/email-address.jpg" alt="My Email"></noscript>
All you need to do is include the snippet in your page source, and replace the email address ‘[email protected]’ and ‘yourdomain.com’.