Javascript – How to open mailto link in Chrome with Window.open without creating a new tab

browser-extensiongoogle-chromegoogle-chrome-extensionjavascript

I am creating a Google Chrome extension and am trying to open a custom url scheme with (window.open) without having a new blank tab open up. For sake of argument lets try the 'mailto' url scheme.

My code:

window.open("mailto://Bob Lawblah", '_self');

Unfortunately this open up a new blank tab as well as opening up the default mail program even though I specified '_self'. According to this I don't seem to be anything wrong.

Any ideas on how to not have an extra tab open when opening a 'mailto' link?

Best Answer

Since this is a chrome extension, there's a different frame of reference for what _self and other targets mean. Instead of trying to use mailto, how about sending them to a site's "Contact Me" page?

I think this offers easier usability for the end user. Honestly, I don't have a default mail application, even if I did have outlook or some dedicated application, I wouldn't use it because GMail is just awesome (personal preference, but I bet I'm not alone). For example, I use an extension to change all mailto links to open GMail so I can email somebody through it. My extensions won't modify your extensions javascript or mailto links (part of the sandboxing).

With a "Contact Me" page, you can not only hide your email address, but allow people to contact you on your terms (no attachments, etc.).

Related Topic