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:
<script>
function myFunc(){
location.href="mailto:test@test.com&body=Hello!";
location.href="newPage.html";
}
</script>
<body onload="myFunc();">
</body>
in IE, this causes the mail client to open with the specified message prepared, and then redirects the browser to newPage.html. Other browsers, however, only redirect to newPage.html. How can I achieve this effect (opening the mail client and then doing a page redirect) consistently across browsers?
As a note, I’ve also tried to accomplish this using meta refresh, but was unsuccessful.
Changing the
hrefproperty 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: