Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Open the href mailto link in new tab / window

I have an image which when click, I want to link to a mailto:

 <a id="mailto" href="mailto:[email protected]" target="_newtab" >         <img src="@Url.Content("~/Content/HomePage/email.png")" alt="email" /></a> 

However, currently once its clicked, it will launch the email option to choose a mailto application, and once i choose, the mailto link is open in the current tab. This will cause user to leave the application.

So, I want the page to sent email (by gmail, yahoo, etc ) is either open in new tab or in a window. Any idea how to do this? I tried both target="_newtab" and target="_blank" but both didn't work.

Any help will be much appreciated.. Thanks...

(jQuery method is also acceptable if there is no other way, thanks)

like image 842
shennyL Avatar asked Dec 18 '11 04:12

shennyL


People also ask

How do I get mailto to open in a new tab?

Use a <form> to let people craft the email first It can even open in a new tab.

How do I open an HREF in a new window?

You just need an anchor ( <a> ) element with three important attributes: The href attribute set to the URL of the page you want to link to. The target attribute set to _blank , which tells the browser to open the link in a new tab/window, depending on the browser's settings.

How do I open a mailto link?

In the General tab, scroll down to the Applications section. Next to Mailto, click the drop-down and change it to Use Gmail. Close the Options tab. Go to a website that has mailto links and click on an email address.


2 Answers

this information is outdated, now it is possible to do so i believe, since gmail and others now work via browser links. there is however the problem that you would only want it to open in a new tab if NOT opening in a system mail client, and open in a new tab if it is a webmail client, otherwise for example Outlook users see a blank tab appear, which is disorienting, especially since they are Outlook users.

like image 97
RedScourge Avatar answered Sep 18 '22 13:09

RedScourge


You don't need Javascript/Jquery for this. A standard link works (except Firefox v30+ due to a bug, see below).

<a href="mailto:[email protected]" target="_blank"> 

As of Firefox 30, does not work in Firefox due to a bug. It opens in the same tab AND replaces history so hitting back will not bring you back to the page where the mailto: link was.

like image 43
Costa Avatar answered Sep 18 '22 13:09

Costa