How to prevent mailto event from opening a new tab in browser

The window.location.href solution by AmShaegar works pretty well but it caused side effect in a complex application I have been developping.

I finally came up with this solution one might be interested in:

$('<iframe src="mailto:[email protected]">').appendTo('body').css("display", "none");

See this plunker: http://plnkr.co/edit/J0LvQU?p=preview


Thank you for the edit. There is indeed an alternative:

window.location.href = "mailto:[email protected]";
alert("Thank you!");

I don't want to use window.location.href since I am displaying a message after the user sent the email.

I did not really get this one. You are not leaving the website when using mailto: with window.location.href