A safe and convenient way to have an email address on a web page
You want to put your email address on a web page so it’s easy for genuine visitors to contact you, but you also want to prevent malicious bots from harvesting your email address and targeting it with spam.
Try our solution. We’ll even generate all the code you need!
Use a read-only, auto-selecting text box that makes it easy for a visitor to copy your email address, plus a button that provides a standard mail-to link:
With this approach, it means:
- When a user clicks on the email address, the whole thing is selected, ready for them to copy and paste.
- Only providing a “mailto” link can be annoying for your visitor if they use a browser-based email solution such as Gmail or Hotmail.
(iPads don’t allow users to select text in a read-only text box. But they can still use the button.)
First, create a read-only text box that auto-selects its contents when clicked:
Add the button:
In the code that follows, you’ll need to replace **name** and **server.com** with the two parts of the email address you want to display:
- **name** should have everything from the email address that comes before the @,
- **server.com** should have everything from the email address that comes after the @.
That’s the only change you need to make to this code:
nameStr = "**name**";
serverStr = "**server.com**";
= nameStr + "@" + serverStr;
Create your code
To easily create the code for your web page, enter your email address in the email address box below and click Get code. Then just copy the code and paste it into your web page!