0

I have a silverlight application in which I need to fire signout event if user navigates away. I have tried a sample function as

window.onunload = function test() { alert("test"); }

The problem is when I navigate away from the webpage the event fires, but I need this event to fire when user closed browser or tab.

Rajat Saini
  • 557
  • 7
  • 26
  • You can not do this, what happens when the browser crashes, they just close the window, etc. You will not get the event on the server. Use session timeouts! – epascarello Sep 19 '13 at 14:02
  • 1
    You could find your answer http://stackoverflow.com/questions/6622461/how-to-capture-browser-close-event-in-javascript – Beniamin Szabo Sep 19 '13 at 14:03

1 Answers1

0

In my case it was not necessary that the page prompts user if he is sure he wants to exit. So I called my signout method inside the 'window.onbeforeunload' event(also flashed a message box to so that webservice gets enough time to successfully signout). Also used

document.onbeforeunload = undefined;

inside my 'window.onbeforeunload' event to avoid the confirmation window.

Rajat Saini
  • 557
  • 7
  • 26