How can I launch the eMail client, and then do a page redirect with Javascript?

前端 未结 4 637
误落风尘
误落风尘 2021-01-14 15:04

I\'m required to make a website function exactly the same on other browsers as it does in IE6. Part of the current code looks similar to this:



        
4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-14 15:24

    This will work only if the client's browser knows which E-Mail client to open for mailto: links in the first place. If the user uses a web-based client that is not registered with the browser, nothing will happen.

    Also, it could be that security settings prevent mailto: links from opening programmatically, or will prevent it in the future.

    I wouldn't rely on this to work either way, only as a nice optional convenience function.

    Anyway, to answer your question, can you try setting a timeout between the two calls? Maybe the location refresh is just too quick for the browser to catch up.

    location.href="mailto:test@test.com&body=Hello!";
    setTimeout(function(){ location.href = 'newPage.html' },  500);
    

提交回复
热议问题