How to call a function before leaving page with Javascript

前端 未结 8 588
遇见更好的自我
遇见更好的自我 2020-12-05 13:50

I would like to execute a function before leaving page without showing a confirmation popup with Javascript only. I\'ve tried with the code below but it did

8条回答
  •  情书的邮戳
    2020-12-05 13:58

    I simple put this code and works preety well

    window.onbeforeunload = function(event) {
        $('element').show();
        return;
    };
    

提交回复
热议问题