var n = window.event.screenX - window.screenLeft;
var b = n > document.documentElement.scrollWidth-20;
if (b && window.event.clientY < 0 || window.event.altKey) {
//页面关闭
} else {
//页面刷新
}
文章来源于:https://blog.csdn.net/qq_43598475/article/details/103055018