window.location.href跳转无效

来源:互联网 发布:下载淘宝自动挂机软件 编辑:程序博客网 时间:2024/05/16 10:42


1)type="submit"时,取消form体。

2)type="button"时,加上form体。

其他情况http://blog.csdn.net/zzq900503/article/details/50879278

------------------------------------------------------------------------------------------------------------------------------------------------

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
</head>

<body>
    <table width="530" height="418" align="center" border="1" bordercolor="#FFCCFF" cellpadding="3" cellspacing="2" background="images/a10.jpg">
    
        <tr>
            <td width="516" height="412" valign="top">
            <table width="516" border="1" bordercolor="#FFCCCC" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="161" height="74">&nbsp;</td>
                    <td width="345">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                </tr>
                <tr>
                    <td height="285">&nbsp;</td>
                    <td valign="top">
                    <table width="100%" border="1" bordercolor="#FFCCCC" cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="350" align="center" valign="middle">用户注册协议</td>
                        </tr>
                        <tr>
                            <td style=" font-weight:inherit">
                                <ul>
                                    <li>炎黄虞夏商,周到战国亡,秦朝并六国,嬴政称始皇。</li>
                                    <li>楚汉鸿沟界,最后属刘邦,西汉孕新莽,东汉迁洛阳。</li>
                                    <li>末年黄巾出,三国各称王,西晋变东晋,迁都到建康,</li>
                                    <li>拓跋入中原,国分南北方,北朝十六国,南朝宋齐梁,</li>
                                    <li>南陈被隋灭,杨广输李唐,大唐曾改周,武后则天皇,</li>
                                    <li>残皇有五代,伶官舞后庄,华歆分十国,北宋火南唐,</li>
                                    <li>金国俘二帝,南宋到苏杭,蒙主称大汗,最后被明亡,</li>
                                    <li>明到崇帧帝,大顺立闯王,金田太平国,时适清道光,</li>
                                    <li>九传至光绪,维新有康梁,换位至宣统,民国废末皇,</li>
                                    <li>五四风雨骤,建国存新纲,抗日反内战,五星红旗扬。</li>
                                </ul>
                            </td>
                        </tr>
                        <tr>
                            <td align="center">
                                            <!--方案一-->
                           <!--
                            <form name="form1" action="#" method="post">
                                <input type="button" name="button" value="同意" onclick="window.location.href='429_1_1.php'" />
                                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                                <input type="button" name="button1" value="不同意" onclick="window.location.href='https://www.baidu.com/'" />           
                            </form>
                           -->
                           
                           
                                                <!--方案二-->
                                <input type="submit" name="Submit" value="同意" onclick="window.location.href='429_1_1.php'" />
                                &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
                                <input type="submit" name="Submit1" value="不同意" onclick="window.location.href='https://www.baidu.com/'" />           
                            
                           
                           
                            </td>
                        </tr>   
                    </table>
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td height="45">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
            </table>
            </td>
        </tr>
    </table>
</body>
</html>

-----------------------------------------------------------------------------------------------------------------------------------

<!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">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>

<script language="javascript">
    function check(){
        if(form1.truename.value==""){
            alert("please inpurt your real name!");
            form1.truename.focus();
            return false;
        }
        if(form1.pwd1.value==""){
            alert("please inpurt your password!");
            form1.pwd1.focus();
            return false;
        }
        if(form1.pwd1.value.length<6){
            alert("least six!");
            form1.pwd1.focus();
            return false;
        }
        if(form1.pwd2.value==""){
            alert("please inpurt your password agian!");
            form1.pwd2.focus();
            return false;
        }
        if(form1.pwd1.value!=form1.pwd2.value){
            alert("pwd1!=pwd2");
            
            return false;
        }
        if(form1.email.value==""){
            alert("please inpurt your email!");
            form1.email.focus();
            return false;
        }
        var i=form1.email.value.indexof("@");
        var j=form1.email.value.indexof(".");
        if((i<0)||(i-j>0)||(j<0)){
            alert("wrong email!");
            form1.email.focus();
            return false;
        }
        form1.submit();
    }
</script>

</head>

<body>
    <form name="form1" method="post" action="#">
    <table width="530" height="418" align="center" border="1" bordercolor="#FFCCFF" cellpadding="3" cellspacing="2" background="images/a10.jpg">
    
        <tr>
            <td width="516" height="412" valign="top">
            <table width="516" border="1" bordercolor="#FFCCCC" cellpadding="0" cellspacing="0">
                <tr>
                    <td width="161" height="74">&nbsp;</td>
                    <td width="345">&nbsp;</td>
                    <td width="10">&nbsp;</td>
                </tr>
                <tr>
                    <td height="285">&nbsp;</td>
                    <td valign="top">
                    <table width="100%" border="1" bordercolor="#FFCCCC" cellpadding="0" cellspacing="0">
                        <tr>
                            <td width="32%" height="23" align="center">username</td>
                            <td width="68%">
                                <input type="text" name="username" id="username" size="20" />
                            </td>
                        </tr>
                        <tr>
                            <td height="22" align="center">truename</td>
                            <td height="22">
                                <input type="text" name="truename" id="truename" size="20" />
                            </td>
                        </tr>
                        <tr>
                            <td height="18" align="center">password</td>
                            <td height="18">
                                <input type="password" name="pwd1" id="ped1" size="20" />
                            </td>
                        </tr>
                        <tr>
                            <td height="19" align="center">surepassword</td>
                            <td height="19">
                                <!--<input type="password" name="pwd2" id="pwd2" onblur="javascript:if(this.value!=this.form.pwd1.value){ alert('您两次输入的密码不一致!');}" />
-->
                                <input type="password" name="pwd2" id="pwd2"  />                           
                            </td>
                        </tr>
                        <tr>
                            <td width="20" align="center">sex</td>
                            <td>
                                <input type="radio" name="sex" value="boy" checked="checked" />boy
                                <input type="radio" name="sex" value="girl" checked="checked" />girl
                            </td>
                        </tr>
                        <tr>
                            <td height="22" align="center">phone</td>
                            <td>
                                <input type="text" name="phone" id="phone" />
                            </td>
                        </tr>
                        <tr>
                            <td height="18" align="center">QQ</td>
                            <td>
                                <input type="text" name="qq" id="qq" />
                            </td>
                        </tr>
                        <tr>
                            <td height="25" align="center" style="padding-left:10px">email</td>
                            <td>
                                <input type="text" name="email" id="email" size="28" />
                            </td>
                        </tr>
                        <tr>
                            <td height="21" align="center">homepage</td>
                            <td>
                                <input type="text" name="homepage" id="homepage" size="28" />
                            </td>
                        </tr>
                        <tr>
                            <td height="20" align="center" >address</td>
                            <td>
                                <input type="text" name="address" id="address" size="28" />
                            </td>
                        </tr>
                        <tr>
                            <td height="34"></td>
                            <td>
                                <input type="submit" name="Submit" id="Submit" value="提交" onclick="return check()" />
                                <input type="reset" name="Reset" id="Reset" value="重置" />
                            </td>
                        </tr>
                    </table>
                    </td>
                    <td>&nbsp;</td>
                </tr>
                <tr>
                    <td height="45">&nbsp;</td>
                    <td>&nbsp;</td>
                    <td>&nbsp;</td>
                </tr>
            </table>
            </td>
        </tr>
    </table>
    </form>
    <?php
        $link=mysql_connect("localhost","root","a3141592654")or die("数据库服务器连接失败!".mysql_error());
        mysql_select_db("msphp",$link)or die("数据库连接失败!".mysql_error());
        mysql_query("set names utf-8");
        if($_POST['Submit']=="提交"){
            $username=$_POST['username'];
            $truename=$_POST['truename'];
            $pwd=$_POST['pwd1'];
            $sex=$_POST['sex'];
            $email=$_POST['email'];
            $phone=$_POST['phone'];
            $homepage=$_POST['homepage'];
            $qq=$_POST['qq'];
            $address=$_POST['address'];
            
            $sql=mysql_query("select * from tb_zc where username='$username';");
            $info=mysql_fetch_array($sql);
            if($info){
                echo "<script> alert('username can't use again!!'); </script>";
            }
            else{
                $sqll=mysql_query("insert into tb_zc(username,truename,pwd,sex,email,phone,homepage,qq,address)values('$username','$truename','$pwd','$sex','$email','$phone','$homepage','$qq','$address');");
                if($sqll){
                    echo "<script> alert('success!'); </script>";
                }
                else
                {
                    echo "<script> alert('false!'); </script>";
                }
            }
        }
    
    ?>
</body>
</html>

原创粉丝点击