关闭页面前提示或保存数据

<script type="text/javascript">
  window.onbeforeunload = function(event) {//event写不写都无所谓    这里也可用其他方法操作    执行前提是页面有过修改

          document.getElementById('dd').innerHTML="W3Cschool";//关闭页面这句会执行  firefox 以及 Microsoft Edge可以
      return "数据保存中...";//return必须要
  }

.......

 

<body>
    <p id="dd"></p>

......

posted on 2016-11-25 15:37  --LP--  阅读(339)  评论(0编辑  收藏  举报

导航