<form name="submit1" method="post" action="submit.php">
content
<input name="btnEditOK" type="submit" title="Submit" class="btnbig" value="提交" onclick="javascript:add();"  onmouseover="this.className='btnbig_over'" onMouseOut="this.className='btnbig'" onMouseDown="this.className='btnbig_down'" onMouseUp="this.className='btnbig'" />
</form><script>
function add(){
if(confirm('请再次确认是否为合格品!'))
{
var url = 'detail.php?id=<?php echo $id; ?>';
window.location.href = url;
}
}
</script>
结果点击提交的时候,出现javascript对话框,点“确定”能跳转到sumbit.php页面,但是点击“取消”也是跳转到该页面。
请问如果点击对话框的“取消”按钮,能否回到提交前的页面。假设提交前的页面是a.php。

解决方案 »

  1.   

    if(confirm('请再次确认是否为合格品!'))
    {
            var url = 'detail.php?id=<?php echo $id; ?>';
            window.location.href = url;
    }
    else{
              window.location.href = a.php;
    }
      

  2.   

    忘了加个引号。
    if(confirm('请再次确认是否为合格品!'))
    {
      var url = 'detail.php?id=<?php echo $id; ?>';
      window.location.href = url;
    }
    else{
      window.location.href = 'a.php';
    }
      

  3.   

    不行啊。点击“取消”还是会跳转到submit.php页面啊。
      

  4.   

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml">
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <head runat="server">
      <form name="submit1" method="post" action="submit.php">
    content
    <input name="btnEditOK" type="button" title="Submit" class="btnbig" value="提交" onclick="javascript:add();"  onmouseover="this.className='btnbig_over'" onMouseOut="this.className='btnbig'" onMouseDown="this.className='btnbig_down'" onMouseUp="this.className='btnbig'" />
    </form><script>
    function add(){
        if(confirm('请再次确认是否为合格品!'))
        {
            var url = 'detail.php?id=<?php echo $id; ?>';
            window.location.href = url;
        }
    }
    </script></body>
    </html>
      

  5.   


    type="submit" 改成 type="button",4楼强人!