0

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!

2 Answers 2

4

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>
Sign up to request clarification or add additional context in comments.

1 Comment

Awesome! Short, sweet, and exactly what I needed. Thanks a lot!
1
//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...

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.