1

I'm currently firing an event on onBeforeUnload to handle unwanted exits of the application. It works fine in IE and Firefox and I can logoff WCF duplex clients from my service instance. But it does not work in Chrome.

Is there any workaround for this ? My Chrome callbacks are always throwing timeout exceptions because of this.

Kubi
  • 2,139
  • 6
  • 35
  • 62
  • possible duplicate of [window.onbeforeunload not working in chrome](http://stackoverflow.com/questions/4802007/window-onbeforeunload-not-working-in-chrome) – Peter O. Dec 12 '12 at 16:56
  • yeah i guess this is a duplicate – Kubi Dec 12 '12 at 22:14

1 Answers1

1

Chrome terminates the Silverlight plugin very roughly. Code in the Application.Exit event may not work as expected. But you can ask the user, if he or she really wants to leave the page. Note that the event handler below does not return null.

<script type="text/javascript">
    // should work in chrome.
    window.onbeforeunload = function () { return ""; };
</script>
Benjamin
  • 1,165
  • 7
  • 19
  • I'm currently using this but that function does not work. It only promts a message I can not call my wcf service to do the saving in Chrome. – Kubi Dec 11 '12 at 22:55
  • window.onbeforeunload = confirmExit; function confirmExit() { //alert(_identifier); PageMethods.SignOff(_identifier, OnSignOffComplete); return "?"; } – Kubi Dec 11 '12 at 22:56
  • Okay, now I better understand what's the problem --> see my edit of your question. – Benjamin Dec 12 '12 at 16:48
  • Yesterday I've edited your post, proposing that it's a [duplicate](http://stackoverflow.com/questions/4802007/window-onbeforeunload-not-working-in-chrome). Seems like it hadn't passed the peer review. – Benjamin Dec 13 '12 at 13:49
  • ok yeah it's a duplicate. I fix my problem though I still can't be sure about it – Kubi Dec 13 '12 at 13:53