See, this is a real funny one... I've been investigated further into this problem I seem to be having and it seems to be a way that IE 6 works over FireFox (which runs this fine)... Please, run this code, check it out - on both FireFox and IE 6 (maybe 7 will work too? Not sure)...
// A simple function that gets triggered by a link.
// This runs once the page has loaded
window.onload = function ()
// This should only run, just before a window is closing.
window.onbeforeunload = function ()
// This runs once the page has been unloaded
window.onunload = function ()
<!-- A link to run a simple function -->
// Just show date/time to make sure the page is not refreshing.
var timeNow = new Date();
All I've done here is set up a simple test that runs an alert when the page first loads, when it's just before the unload and the actual unload. Also, I have a function that alerts a mesage when a text link is clicked.
As you'll see... FireFox does it all fine and runs them in correct order... But IE 6 does it differently... It seems to run the window.unbeforeunload when you click on the text link?? Why is this? Seems very odd...
The only way I can seem to get around it is by using this instead:
<a href="#" onclick="clickHere();">Click Here</a>
... where I'm not using the href="" to call the function. Doing it this way round, seems to make everything run correctly in IE 6.
Does anyone know why IE does this, this way? Is there any way around it with out altering much code? Has anyone else ever experienced this problem?
Hope you can help!