[Javascript] Grab close window call

Alan Easton alaneaston666 at hotmail.com
Tue Apr 1 06:30:57 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...> From: davidh126 at writeme.com> To: javascript at lists.evolt.org> Date: Mon, 31 Mar 2008 20:45:23 -0700> Subject: Re: [Javascript] Grab close window call> > On Mon, 31 Mar 2008 23:26:10 +0100, Alan Easton wrote:> > Hi All,> >> > I have a problem, which I am not sure is solvable.> >> > I have a pop up window on my site, that launches a chat window. Now, I would like to> > set a flag in my database, when someone ends the chat. Easy done, if someone clicks the> > "End Session" link in the window, but what if someone simply closes the window by the> > normal means of clicking "close" icon in the top right of the window.> >> > Ideally, I would like to grab that call, and set an Ajax call to update my database.> >> > Is this possible?> >> > I believe the "window.onunload" event is the one you are looking for.> > Cordially,> David> --> > _______________________________________________> Javascript mailing list> Javascript at lists.evolt.org> http://lists.evolt.org/mailman/listinfo/javascript
_________________________________________________________________
Welcome to the next generation of Windows Live
http://www.windowslive.co.uk/get-live
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20080401/50ab168c/attachment.htm>


More information about the Javascript mailing list