So I want to enable a button to open the default email sender on the user's computer (eg Outlook) so they can send us a direct email.
How can I do this with bootstrap buttons and what is the best way to keep bots away.
Thanks
So I want to enable a button to open the default email sender on the user's computer (eg Outlook) so they can send us a direct email.
How can I do this with bootstrap buttons and what is the best way to keep bots away.
Thanks
Just use a mailto link with the correct css style:
<a href="mailto:some@email.com" target="_blank" class="btn btn-primary">Email Us</a>
I was thinking to hide the mailto in javascript. Like below. I think the mail has to be obfuscated in the javascript code as well.
Read more about How to spamproof a mailto link?
Not obfuscated example
$(document).ready(function() {
$('#mailbutton').click(function(event) {
window.location = "mailto:example@example.com";
});
});
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<a href="#" id="mailbutton" class="btn btn-primary">Send us a mail!</a>