onbeforeunload页面离开/刷新事件

2018-03-29  本文已影响0人  佛系码农

chrome浏览器51之前的版本,允许页面离开的时候让开发者弹出自定义的提示信息,51版本(包括51)不允许弹出自定义的窗口。

window.onbeforeunload = function(e) {

    e.returnValue = "A search is in progress, do you really want to stop the search and close the tab?";

    return "A search is in progress, do you really want to stop the search and close the tab?";

}//无效

上一篇 下一篇

猜你喜欢

热点阅读