Click to See Complete Forum and Search --> : Close Browser Window


Himanshu
06-15-2004, 12:23 PM
Hello All,
I have a small problem related to the "close browser button" on the top left corner of the browser.
If the user clicks on it, an alert box should pop up which give the user two choice whether he wants to close the window or not. Also the message displayed should be "If u click on of, your session will be lost" with two buttons "OK" and "don't log off".
Can anyone tell me how to do it...
It's really urgent...
Thanks in advance
Himanshu

sciguyryan
06-15-2004, 12:32 PM
This will do what you ask:


<script type="text/javascript">
<!--
window.close();
//-->
</script>




Hope that helps.

Himanshu
06-16-2004, 11:51 AM
This will not give me the message I want...
I don't want to close the window..
I want to give a message when user presses the close browser button on the browser top left corner....

sciguyryan
06-16-2004, 12:06 PM
Try using onUnload


function Choice(){
var ExitMe = window.confirm("Do you wish to exit the page?");
if (ExitMe == true){
window.close();
}
else{
window.location = "YourIndex.html";
}
}




OnUnload="Choice();"