views:

89

answers:

2

So I am trying to make it so a user clicks a button to email me, a js alert box pops up with a message and then after they click ok it goes forward with the email link. This is my code thus far:

<a href="mailto:[email protected]">
<a href='javascript:window.alert("All reservations must be made by phone!");'>
<img src="http://wfithaca.com/wp-content/themes/zenlite/images/mailicon.png" />
</a>
</a>

Any help would be greatly appreciated!

+4  A: 

Try:

<a href="mailto:[email protected]" onclick="alert('All reservations must be made by phone!');">
<img src="http://wfithaca.com/wp-content/themes/zenlite/images/mailicon.png" />
</a>
Joel Etherton
+1 nice, simple and downgrades gracefully.
Pekka
Brilliant...never thought of it....
The Elite Gentleman
Awesome! Short, sweet, and exactly what I needed. Thanks a lot!
Davey
+1  A: 
//javascript 

function alertAndRedirect(text, email) {
 alert(text);
 window.location.replace("mailto:" + email);
}

<!--HTML -->
<a href='javascript:alertAndRedirect("All reservations must be made by phone!","[email protected]");'>
<img src="http://wfithaca.com/wp-content/themes/zenlite/images/mailicon.png" />
</a>

Hope this helps...

The Elite Gentleman