浏览器onbeforeunload

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
</head>
<body>
<h2>浏览器的各类事件</h2>
<input type="text" name="" id="" value="" />
<script type="text/javascript">
//刷新页面生效 页面内容改变之后离开当前页面 或者关闭当前页面生效
window.onbeforeunload=function(e){ 
  var e = window.event||e; 
  e.returnValue=("肯定离开当前页面吗?");
} 
</script>
</body>
</html>
相关文章
相关标签/搜索