注册 登录
编程论坛 JavaScript论坛

页面转换问题

梦中的你 发布于 2010-09-25 21:18, 437 次点击
<style type="text/css">
<!--
.STYLE1 {font-size: x-large}
.STYLE2 {font-size: large}
-->
</style>
<table width="361" align="center">
  <tr>
    <td height="55" colspan="2" align="center"><span class="STYLE1">使用登陆</span></td>
  </tr>
  <tr>
    <td width="123" align="center"><span class="STYLE2">姓名:</span></td>
    <td width="222"  ><form name="form2" method="post" action="">
      <input type="text" name="textfield">
    </form>
    </td>
  </tr>
  <tr>
    <td align="center"><span class="STYLE2">密码</span>:</td>
    <td ><form name="form3" method="post" action="">
      <input type="password" name="textfield2">
    </form>
    </td>
  </tr>
  <tr>
    <td height="99" colspan="2"><form name="form1" method="post" action=""><div align="center">
      <input type="submit" name="Submit" value="登陆" onclick="zou()"></div>
    </form>
    </td>
  </tr>
  
</table>
<script language="javascript">
function zou()
{
if(form2.textfield.value=="iloveyou"&&form3.textfield2.value=="meto")
{

}else
{alert("输入错误,请重新输入!");
form2.textfield.focus();
return false;
}
}
</script>
就是我通过验证  姓名和密码正确后,想要转换成另一个自己已经做好了的html页面。。。。就是下面这个语句,

if(form2.textfield.value=="iloveyou"&&form3.textfield2.value=="meto")
{

}else
{alert("输入错误,请重新输入!");
form2.textfield.focus();
return false;
}
姓名是 iloveyou 密码是 meto ,正确后,if后面应该怎么做才能正常转入在电脑同一个位置的比如说为my.html的页面????



3 回复
#2
gameohyes2010-09-25 23:19
location.href="temp.html";
#3
gupiao1752010-09-27 15:44
<html>
<head>
<script language="javascript">
function zou()
{
//alert(form2.textfield.value+"#"+form3.textfield2.value);
if(form2.textfield.value=="iloveyou"&&form3.textfield2.value=="meto")
{
window.location='my.html';
}else
{alert("输入错误,请重新输入!");
form2.textfield.focus();
//return false;
}
}
</script>
</head>

<style type="text/css">
<!--
.STYLE1 {font-size: x-large}
.STYLE2 {font-size: large}
-->
</style>
<body>
<table width="361" align="center">
  <tr>
    <td height="55" colspan="2" align="center"><span class="STYLE1">使用登陆</span></td>
  </tr>
  <tr>
    <td width="123" align="center"><span class="STYLE2">姓名:</span></td>
    <td width="222"  ><form name="form2" method="post" action="">
      <input type="text" name="textfield">
    </form>
    </td>
  </tr>
  <tr>
    <td align="center"><span class="STYLE2">密码</span>:</td>
    <td ><form name="form3" method="post" action="">
      <input type="password" name="textfield2">
    </form>
    </td>
  </tr>
  <tr>
    <td height="99" colspan="2"><form name="form1" method="post" action=""><div align="center">
      <input type="button" name="Submit" value="登陆" onclick="zou()"></div>
    </form>
    </td>
  </tr>
 
</table>
</body>
</html>

注意修改的2个地方,一个是window.location=url,HTML跳转常用的方式,还有一个就是登入的按钮要用button!否则无效!因为这是html页面内的跳转!
#4
梦中的你2010-09-28 17:36
回复 3楼 gupiao175
嗯,是这样了!谢谢~
1