JS在即将离开当前页面(刷新或关闭)时触发事件

// onbeforeunload 事件在即将离开当前页面(刷新或关闭)时触发
	window.onbeforeunload = function () {
		return /^\#\/ipinfo/.test(location.hash) || /^\#\/ipdetail/.test(location.hash) ? '您正处于编辑状态,确认离开该页面么?' : null;
	};

  

posted @ 2018-04-11 18:15  横十条  阅读(1129)  评论(0编辑  收藏  举报