瀏覽器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>
相關文章
相關標籤/搜索