Skip to content Skip to sidebar Skip to footer

Second `window.location = Mailto:` Fails As Long As First One Is Still Open

I'm trying to open the local mail window using the javascript window.location.href=mailto:. However, my addresses exceed the maximum length. So I slice it into pie

Solution 1:

The sample script below works for me on localhost

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

When on Fiddle, it seems to be working 75% of the time (with ad blocker turned on).

There is a risk that popup and ad blockers, anti-virus software etc. may silently block forced opening of multiple mailto links.

Post a Comment for "Second `window.location = Mailto:` Fails As Long As First One Is Still Open"