第二`窗口.location= mailto:`只要第一个仍打开,就会失败



我正在尝试使用JavaScript window.location.href=mailto:<addresses>打开本地邮件窗口。但是,我的地址超过了最大长度。因此,我将其切成碎片,然后在特定的超时之后将它们互相发送。但是,如果第一个仍然打开,第二个搬迁将不会打开新的(Outlook)邮件窗口...是否有任何方法可以解决此问题?还是有其他/更好的方法可以在本地客户端打开多个邮件窗口?

任何帮助将不胜感激!

代码:

function Send_Mails(mails) {
var timeout = 2000;
var maxUrlCharacters = 1900;
var currIndex = 0;
var nextIndex = 0;
if (mails.length < maxUrlCharacters) {
    window.location = 'mailto:' + mails;
    return;
}
do {
    currIndex = nextIndex;
    nextIndex = mails.indexOf(';', currIndex + 1);
} while (nextIndex != -1 && nextIndex < maxUrlCharacters)
if (currIndex == -1) {
    window.location = 'mailto:' + mails;
} else {
    window.location = 'mailto:' + mails.slice(0, currIndex);
    setTimeout(function () {
                Send_Mails(mails.slice(currIndex + 1));
                }, timeout);
}
}

这可以正确打开第一个MailWindow,但是只要第一个打开,第二个都不会打开。

最好的问候,汉斯

下面的示例脚本在localhost

上对我有用
<button onclick="openmail()">Open mail</button>
<script>
    function openmail(){
        window.location.href="mailto:test1@test.org"
        setTimeout(function(){
            console.log('2nd email');
            window.location.href="mailto:test2@test.org"
        }, 3000);
    }
</script>

在小提琴上时,它似乎有75%的时间工作(AD Blocker打开)。

存在弹出窗口和广告阻滞剂,防病毒软件等的风险,可能会默默阻止强迫打开多个邮件链接。

最新更新