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

前端 未结 4 586
误落风尘
误落风尘 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:09

    Changing the href property will start a location load, changing it again afterwards will cancel the previous navigation.

    It appears that IE6 will start the e-mail client immediately upon setting the property, then continue the javascript execution. Other browsers appear to do things differently, and the second location load will cancel the first.

    I managed to work around this in Chrome with a timer, it might work for other browsers too:

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

提交回复
热议问题