已经尝试使用了beforeunload:
$(window).bind('beforeunload',function(){
var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth-20;
if(window.event.clientX>document.body.clientWidth && window.event.clientY < 0 || window.event.altKey)
{
console.log("是关闭而非刷新");
window.event.returnValue = "确认离开?";
return '确认离开?';
}else{
console.log("是刷新而非关闭");
window.event.returnValue = "是刷新";
return '是刷新';
}
});
我关闭浏览器也是提示我刷新而不是关闭,请问有什么方式可以解决?
楼主有没有找到解决的办法?