0

I am facing the problem to logout my page. I calls the logout method from the tag of the page like this

<body onbeforeunload="beforeLogout();" onUnload="logout('/ruxamod/faces/zzrucmpvhs1.xhtml?logout=t');" onclick="hideDescFrame();">

but I have no idea how to trap the window close button is clicked because all these methods are call when user refresh the page.

Thanks

Felix Kling
  • 795,719
  • 175
  • 1,089
  • 1,143
  • You can take a look at the following links: http://stackoverflow.com/questions/4268866/catching-a-browser-close-event
    http://stackoverflow.com/questions/5367232/detect-close-window-event-in-firefox
    – Jan S Sep 07 '11 at 07:47
  • Can you elaborate a little more on your problem statement? Do you want to create a link on a page for logout and close the same window? – Manish Singh Sep 07 '11 at 07:57
  • No i am not creating a link for logout I want that if user click the close button of the browser window then it should be logout the page. – prashant mishra Sep 07 '11 at 08:17

1 Answers1

1

I have no idea how to trap the window close button is clicked

As far as I know, there is no way to do this. You can't find out the reason why the document is getting unloaded.

You may be able to catch this by frequently polling from the opener document whether the window is still open.

Alternatively, you could consider using an inline dialog like jQuery UI dialog where you can catch all events.

Pekka
  • 442,112
  • 142
  • 972
  • 1,088