return false 也会继续执行下去了

解决方案 »

  1.   

    onclick="sureButton()"  应该写在<form onsubmit="return sureButton();"> return false才有效
      

  2.   

    <input onclick="sureButton()" type="submit" value="确定" name="B1" style="border-style: outset; border-width: 1; color:#0000FF"> 
    <script language="javascript">      
    function sureButton(){      
      if(!confirm('确认?!')){      
          return true;      
      }    else{ 
      return  false; 
      }        

    </script> 
    <? 
    echo "ok!!!"; 
    ?> 
    首先你要确认一点。js 是客户端执行的,php 是服务器端执行的,就是说当你的js还没有执行的时候,php已经执行完毕了,所以你这么写实没用的
    <input onclick="return sureButton()" type="submit" value="确定" name="B1" style="border-style: outset; border-width: 1; color:#0000FF"> 
    <script language="javascript">      
    function sureButton(){      
      if(confirm('确认?!')){      
          window.location='b.php';      
      }    else{ 
      return  false; 
      }        

    </script> b.php 来执行你的echo