0

How do I capture the browsers Tab Close-event in JavaScript or EXTJS. I have tried the following:

<script>
    window.onunload = (function(){
        return 'stay page ......';
    });
</script>

as well as

<script>
   window.onbeforeunload = (function(){
      return 'stay page ......';
   });
</script>

but this onunload is not working and onbeforeunload is working for page refresh and page close events. Please help me.

http://stackoverflow.com/questions/3888902/javascript-detect-browser-close-tab-close-browser

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
Manjula
  • 51
  • 1
  • 3

1 Answers1

0

Have u tried this?

Ext.EventManager.on(window, 'beforeunload', function() {
alert('cross-exit tab click AND cross-exit browser click');
});

Ext.EventManager.on(window, 'unload', function() {
alert('cross-exit tab click');
});
Sparrow
  • 355
  • 4
  • 19