浏览器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>

  

猜你喜欢

转载自www.cnblogs.com/mary-123/p/11249222.html