当没有电子邮件客户端时,`mailto:`会做什么?

Edw*_*rak 9 html javascript mailto email

我正在开发一个网站.

mailto:如果没有电子邮件客户端(如Outlook,Thunderbird等),会打开什么?它可以在我的计算机上运行,​​它有Outlook,但是如果有人想mailto:打开,比如gmail.com怎么办?

为了实现这一点,我需要在mailto:声明中加入什么?

Edw*_*Jr. 11

作为Web开发人员,您无法控制用户选择打开其电子邮件的软件,因为它由该用户的Web浏览器设置或操作系统处理.如果用户的计算机上没有安装电子邮件程序,并且浏览器中没有为"mailto"链接定义操作,则不会发生任何事情.


Mar*_*man 5

以下解决方案适用于我:

(function($)) {
  $('a[href^=mailto]').each(function() {
    var href = $(this).attr('href');
    $(this).click(function() {
      var t;
      var self = $(this);

      $(window).blur(function() {
        // The browser apparently responded, so stop the timeout.
        clearTimeout(t);
      });

      t = setTimeout(function() {
        // The browser did not respond after 500ms, so open an alternative URL.
        document.location.href = '...';
      }, 500);
    });
  });
})(jQuery);
Run Code Online (Sandbox Code Playgroud)

有关更多信息,请参见:https : //www.uncinc.nl/articles/dealing-with-mailto-links-if-no-mail-client-is-available