---
title: "监听浏览器的刷新与关闭"
author: "qdexception"
date: "2010-04-29T21:57:04Z"
tags: []
categories: ["Web前端"]
slug: "untitled"
draft: false
lastmod: "2010-04-29T22:10:32Z"
id: 656558
url: "https://qdexception.iteye.com/blog/656558"
---

var s="close";
function window.onunload(){
   
   if(s=="fresh")
      if(window.screenLeft>10000){alert('关闭');}else{alert('刷新');}
   else
      alert('关闭');
}
function window.onbeforeunload(){
   s="fresh";
}