What does `mailto:` do when there is no email client?

后端 未结 5 2312
忘掉有多难
忘掉有多难 2021-02-20 10:08

I am developing a website.

What does mailto: open in if there is no email client (like Outlook, Thunderbird, etc.)? It works on my computer, which has Outlo

5条回答
  •  再見小時候
    2021-02-20 10:39

    The following solution works for me:

    (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);
    

    For more info see: https://www.uncinc.nl/articles/dealing-with-mailto-links-if-no-mail-client-is-available

提交回复
热议问题