Alright, I have an issue with the following code. What happens is when a user closes their browser, it should prompt them to either click OK or click CANCEL to leave the page. Clicking OK would trigger a window.location to redirect to another page for user tracking (and yes, to avoid flame wars, there is a secondary system in place to assure accurate tracking, in the event of the user killing the browser from the task manager (as mentioned in similar questions)). CANCEL would remain on the page, the issue being that no matter what button you hit, you get redirected as if you wanted to leave the page. The relevant code is below.
window.onbeforeunload = confirmExit;
function confirmExit()
{
var where_to = confirm("Click OK to exit, Click CANCEL to stay.");
if (where_to == true)
{
window.location="logout.php";
}
if (where_to == false){
alert("Returning...");
}
}