有没有办法在单击时通过JavaScript打开多个电子邮件客户端?我知道如何使用mailto,但不知道如何打开多个客户端。这段代码会在每次重新加载时打开客户端。
window.location.href = "mailto:user@example.com?subject=Subject&body=message%20goes%20here";
任何关于此事的帮助,谢谢。
有没有办法在单击时通过JavaScript打开多个电子邮件客户端?我知道如何使用mailto,但不知道如何打开多个客户端。这段代码会在每次重新加载时打开客户端。
window.location.href = "mailto:user@example.com?subject=Subject&body=message%20goes%20here";
<button class="button">Open Email</button>
使用 jQuery:
$(document).ready(function(){
$('.button').on('click',function(){
window.location.href = "mailto:user@example.com?subject=Subject&body=message%20goes%20here";
});
});
更新
如果您想要加载多个客户端实例,只需复制 window.location.href
:
$(document).ready(function(){
$('.button').on('click',function(){
window.location.href = "mailto:user@example.com?subject=Subject&body=message%20goes%20here";
window.location.href = "mailto:user@example.com?subject=Subject2&body=message%20goes%20here";
});
});
在浏览器中无法从JavaScript启动外部应用程序。mailto仅会启动在系统设置中配置为默认值的MUA。