How to disable beforeunload action when user is submitting a form?

前端 未结 7 2347
伪装坚强ぢ
伪装坚强ぢ 2020-11-28 12:48

I have this little piece of code:



        
7条回答
  •  -上瘾入骨i
    2020-11-28 13:04

    Call unbind using the beforeunload event handler:

    $('form#someForm').submit(function() {
       $(window).unbind('beforeunload');
    });
    

    To prevent the form from being submitted, add the following line:

       return false;
    

提交回复
热议问题