How can I override the OnBeforeUnload dialog and replace it with my own?

前端 未结 11 2029
一生所求
一生所求 2020-11-21 06:14

I need to warn users about unsaved changes before they leave a page (a pretty common problem).

window.onbeforeunload=handler

This works bu

11条回答
  •  南方客
    南方客 (楼主)
    2020-11-21 07:11

    Try placing a return; instead of a message.. this is working most browsers for me. (This only really prevents dialog's presents)

    window.onbeforeunload = function(evt) {            
            //Your Extra Code
            return;
    }
    

提交回复
热议问题