[Javascript] Grab close window call

Rees, Mark Mark.Rees at astrazeneca.com
Tue Apr 1 07:11:15 CDT 2008


 
Hello,
 
Thanks for the advice so far.
 
What I have done is this. I have a page, that launches a pop window. Now, on the pop up window, I have this code in the <head>
 
----------------------------
 
<script language="javascript">
window.onbeforeunload=confirmExit;
function confirmExit(){
return "Do u want to close this page?"
}
</script>
 
----------------------------
 
But I need to change the "return" statement to grab if they click "OK" or Cancel", as if they click "OK", I want to grab this and fire of an ajax call, and same goes for if the click "Cancel" I need to fire off an ajax call if they do that as well.
 
How can I alter that "return" statement to cope with these 2.
 
Any ideas would be great.
 
Thanks,
 
Alan...
 
Use "confirm", like this

 if(confirm('do you want to close this page')){
    //do this
}else{
    //do that
} 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20080401/fd1bb2f1/attachment.htm>


More information about the Javascript mailing list