March 31, 2012
How to make a link navigate to another page and also mailto an email?
Question by Doug Firr
I’d like a link where if someone clicks a mailto link they are also shown a different page.
What would the html look like? Currently:
<a href="mailto:someone@mail.com">email</a>
Any ideas?
Answer by Starx
Use Javascript’s window.location on the click event of the link
<a href="mailto:someone@mail.com" onclick="window.location=another.html">email</a>
Update:
If you have to stack up lots of code in the onclick event, create a function instead
function handleClick() {
_gaq.push(['_trackEvent', 'emails', 'clicked', 'lead']); //first this
window.open = 'anotherpage.html'; //or window.location for redirection
}
HTML
<a onclick="handleClick()" href="mailto:someone@mail.com">email.com</a>