页面关闭时触发事件 Posted on 2007-07-09 11:40 yiki 阅读(1542) 评论(3) 编辑 收藏 网摘 所属分类: JScript < script language = " javascript " > window.onbeforeunload = function () { if(!(event.clientX>document.body.clientWidth&&event.clientY<0||event.altKey)) { //在刷新、或以_self方式转到其它页面、或用ALT+CTLR+DEL关闭时触发; //代码 } else { //点击工具栏上的[X]按钮、或ALT+F4关闭时触发 }} </ script > window.onbeforeunload = function() { if((event.clientX>document.body.clientWidth&&event.clientY<0)||event.altKey) { //alert("关闭触发"); } else { //alert("刷新触发"); } } 转载于:https://www.cnblogs.com/China-Dragon/archive/2009/12/18/1627041.html