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:wildfire@wfithaca.com.com">
<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!
Try:
<a href="mailto:wildfire@wfithaca.com.com" onclick="alert('All reservations must be made by phone!');">
<img src="http://wfithaca.com/wp-content/themes/zenlite/images/mailicon.png" />
</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!","wildfire@wfithaca.com.com");'>
<img src="http://wfithaca.com/wp-content/themes/zenlite/images/mailicon.png" />
</a>
Hope this helps...
精彩评论