A solution is to define a Javascript function that handles the mailto inside it.
function Link_OnClickEvent() {
$("#Comment").hide();
window.open("mailto:coded@mail.com", "_blank");
}
Note: You can also use this method if you want to dynamically define the email subject, content or mailto address.
The last line can be considered a bad practice nowadays. The reason is that it opens unnecessary window, and completely bypasses user preference. You might want to consider using location.href (I have not personally tried it, given my resistance towards having a publicly visible email address).
ReplyDeleteWould you enlighten us as to why onclick attribute does not work properly with mailto? This test works (albeit I've only tried it in Chrome):
<script>
function onClick() {
alert('test');
}
</script>
<a href="mailto:test@test.com" onclick="onClick();">Test</a>