1、首先在你所写的页面里面body标签里面写上onbeforeunload属性
<body onbeforeunload="checkLeave()">...此处省略html页面代码</body>
2、然后到js里面去实现checkLeave()这个方法
function checkLeave() {var e = window.event || e;e.returnValue = "确定离开当前页面吗?";return "未完成操作,是否离开";}
时间:2024-05-18 02:11:55
1、首先在你所写的页面里面body标签里面写上onbeforeunload属性
<body onbeforeunload="checkLeave()">...此处省略html页面代码</body>
2、然后到js里面去实现checkLeave()这个方法
function checkLeave() {var e = window.event || e;e.returnValue = "确定离开当前页面吗?";return "未完成操作,是否离开";}