如何使用Window.open在Chrome中打开mailto链接而不创建新标签? [英] How to open mailto link in Chrome with Window.open without creating a new tab?

查看:273
本文介绍了如何使用Window.open在Chrome中打开mailto链接而不创建新标签?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个Google Chrome浏览器扩展程序,并试图在不打开新的空白标签的情况下使用(window.open)打开自定义网址方案。为了讨论起见,我们尝试使用'mailto'网址方案。



我的代码:

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

不幸的是,这打开了一个新的空白标签,并打开了默认的邮件程序,即使我指定了'_自'。根据,我似乎没有任何问题。



关于如何在打开'mailto'链接时不打开额外标签的任何想法?

解决方案

由于这是一个扩展名,所以对于_self和其他目标的含义有不同的参照系。而不是试图使用mailto,如何将它们发送到网站的联系我页面?

我认为这为最终用户提供了更容易的可用性。老实说,我没有默认的邮件应用程序,即使我有Outlook或某些专用应用程序,我也不会使用它,因为GMail非常棒(个人喜好,但我敢打赌,我并不孤单)。例如,我使用扩展名更改所有mailto链接以打开GMail,以便我可以通过电子邮件向某人发送电子邮件。我的扩展程序不会修改您的扩展javascript或mailto链接(沙盒的一部分)。



通过联系我页面,您不仅可以隐藏自己的电子邮件地址,但允许人们根据您的条款与您联系(无附件等)。

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?

解决方案

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

这篇关于如何使用Window.open在Chrome中打开mailto链接而不创建新标签?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆