//php
if(!empty($_GET['cloDept']) && !empty($_GET['cloUnit'])){
        $mysql->removeAlarm($_GET['cloUnit'],$_GET['cloDept']);
        echo "<script language='javascript'>alert('refresh-->><<');
        Response.Cache.SetCacheability(System.Web.HttpCacheability.NoCache);
        Response.Expires = 0;
        Response.Buffer = true;
        Response.ExpiresAbsolute = DateTime.Now.AddSeconds(-1);
        Response.AddHeader('pragma', 'no-cache');
        Response.CacheControl = 'no-cache';
        </script>";
        header('index.php');
    }<Meta http-equiv="Refresh" Content="10">
<a style='font-size:12px' href='map.php?cloDept=<?=$s['dept']?>&cloUnit=<?=$s['unit']?>'>提交</a>

解决方案 »

  1.   

    问题:点击提交后,页面总会重复执行a链接的操作,php中的echo是一段清除缓存的代码,为什么没用?
    a链接正常,还有这种也不行:<?php
      if(!empty($_GET['cloDept']) && !empty($_GET['cloUnit'])){
    $mysql->removeAlarm($_GET['cloUnit'],$_GET['cloDept']);
    header('index.php');
    }
    ?>
    <script>
      var checkSubmitFlg = false;
        function checkSubmit() {
          if (checkSubmitFlg == true) {
             return false;
          }
          checkSubmitFlg = true;
          return true;
       }
       document.ondblclick = function docondblclick() {
          window.event.returnValue = false;
       }
       document.onclick = function doc {
           if (checkSubmitFlg) {
             window.event.returnValue = false;
           }
       }
    </script>
    <a style='font-size:12px' href='map.php?cloDept=<?=$s['dept']?>&cloUnit=<?=$s['unit']?>'>提交</a>
      

  2.   

    解决了,用php新建一个中转页面进行数据库操作。js和PHP两方面都要防止刷新,而我只防止了JS。
    好吧,来个人,结贴了。