JavaScript + onbeforeunload

后端 未结 6 1288
盖世英雄少女心
盖世英雄少女心 2020-11-30 09:30

I have a query regarding my application. Whenever user closes browser window accidentally I\'d want to do some clean up operations before that. I have used onunload event bu

6条回答
  •  鱼传尺愫
    2020-11-30 10:32

    window.onbeforeunload = function() {
        return 'You have unsaved changes!';
    }
    

    See the MSDN article on onbeforeunload

    Also there is a similar question in SO

提交回复
热议问题