Execute function before refresh

前端 未结 4 1873
深忆病人
深忆病人 2020-11-29 06:40

On my HTML page, when the user clicks / presses F5 button the page refreshes, but before it refreshes I want to execute a function or a simple alert.

Use

4条回答
  •  野性不改
    2020-11-29 07:18

    $(window).bind("beforeunload", function(){
            return confirm("Do you really want to refresh?"); 
    });
    

提交回复
热议问题