JS判断是否离开当前页面

关闭页面的时候弹出提示框

 

<!doctype html> 
<html> 
<head> 
<meta charset="UTF-8"> 

<title>Leave Page</title> 
<script type="text/javascript"> 
window.onbeforeunload = function() 
{  
	return "Leave this page?"; 
} 
</script> 
</head> 
<body> 
Contents...
</body> 
</html> 

  

posted @ 2015-02-11 10:10  batter152  阅读(5835)  评论(0编辑  收藏  举报