Forum Moderators: open
<script>
function HandleUnLoad(){
window.top.location.href = "logout.htm";
}
</script>
...
<body onUnLoad="HandleUnload()" ....
This works fine for all browsers and UnLoad events EXCEPT for Refreshing on IE5.5/6. In these browsers the logout.htm page is called for a fraction of a second before being replaced by the page you clicked refresh on.
Any ideas on ways around this? Thanks in advance for you help. :)
Josh
The onUnload() method was originally conceived as a way to run a short clean-up script that would undo any lingering effects of scripts run in the window; in essence, a way to take out the garbage. Nevertheless many people use it for other purposes, the notorious exit pop-up window being a prime offender.
None of which solves your problem, I realize. I was considering a script to tell the difference between a refresh and other types of unLoad, but there's no way for JavaScript to detect what page is going to load next (that would create a big security hole).
You've go me stymied.
We've managed to get around it by inserting a small page containing js.
If this loads the onLoad event redirects it to the logout page. If it doesn't finish loading then the browser action just continues... this is fine as the problem only occurs on a refresh.
A bit of browser sniffing avoids doing this unnecessarily.
J