Forum Moderators: open
<script>
<!--
var your_message = "Are you sure you want to leave?";
var times = 0;
function onul() {
if (times == 0) {
var leave = confirm(your_message);
if (!leave) location = self.location;
times++;
}
}
//-->
</script>
<body onunload="onul()">
When a user leaves a page, it asks if they really want to, and they have the option of selecting OK or cancel.
I'm wondering how to make it so when you press OK, it will just display the same alert again, and when cancel is selected it will stay on the page, not displaying the alert again unless they try to leave the page. Yes sort of like a trap, don't ask ;)
Thanks!
Kaled.