开发者

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

开发者 https://www.devze.com 2023-03-29 00:34 出处:网络
I am crea开发者_StackOverflowting 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 \'mai

I am crea开发者_StackOverflowting 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?


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.).


Since you're in a Chrome Extension context, you should be using chrome.tabs APIs. If you have an extra tab floating around, you can just close it via http://code.google.com/chrome/extensions/tabs.html#method-remove

0

精彩评论

暂无评论...
验证码 换一张
取 消