Hi Guys,

I am working on a struts based application. I need to meet a special
requirement that is when user clicks the X button on the browser the browser
should not close immediately rather we should show a confirm box. if user
says yes in the confirm box then only browser should close.

i am trying with the following code

<html><head>
<script>
function doUnload()
{
if (window.event.clientX < 0 && window.event.clientY < 0)
{
 var answer=confirm("Window is closing...");
 if (answer){
  alert("Bye bye!");
  return true;
  //window.close();
 }
 else{

  alert("Thanks for sticking around!");
  return false;
 }
}
}
</script>
</head>
<body onunload="return doUnload();">
<a href="http://www.google.com";>google</a>
</body></html>


but no luck able to see the confirm box but the window is getting closed .

Please suggest some idea

Thanks
Kranti

Reply via email to