检测mailto失败的时间 [英] detecting when mailto failed

查看:70
本文介绍了检测mailto失败的时间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当使用mailto链接时,如果他没有设置电子邮件客户端,或者没有将他的网络邮件设置为他的默认客户端,那么它对用户没有任何作用(例如, gmail作为macosx中的默认客户端)。
什么是优雅提供后备的最佳方式,请用户手动给您发送电子邮件?
我可以使用JS或css在点击链接后显示消息:

When using a mailto link chances are that it doesn't do anything for the user if he doesn't have an email client setup, or didn't setup his webmail to be his default client (ea. gmail as default client in macosx). What would be the best way to gracefully offer a fallback, kindly asking the user to manually email you? I could use JS or css to show a message once the link has been clicked:


提交成功,或者如果没有发生了请手动给我们发电子邮件。

submit was successful, or if nothing happened please email us manually.

如果使用带有mailto的表单,我可以成功使用重定向页面,无需或使用服务器端脚本?有没有办法过滤失败的成功,而不是依赖用户对上面的双重成功/失败消息的判断?

What about using a form with mailto, can I use a redirect page upon success without or with serverside scripting? Is there a way to filter out the success from failure, instead of relying on the user's judgement with the double success/failed message above?

编辑:至少会是什么单击mailto链接(或表单)时更改状态的最合适方式。显然JavaScript或CSS是选项,但我不能简单地创建双动作链接或表单提交; mailto并链接到另一个页面(你已经提交/点击了按钮')

edit: At least what would be the most suitable way of changing a state when a mailto link (or form) has been clicked. Obviously JavaScript or css are options, but can't I simply create a double action link or form submit; mailto and also link to another page (you have submitted/clicked the button')

推荐答案

本文讨论检查是否存在 window 点击mailto后触发的模糊事件。它使用超时,所以它不是万无一失的,但可以解决大多数情况。

This article discusses a hack of checking if the window's blur event fired after clicking the mailto. It uses a timeout, so it's not foolproof, but might address most cases.

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

这篇关于检测mailto失败的时间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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