我使用这个代码做了一个登陆界面 修改用户名和密码以后任然不能跳转到我想要的页面(我想跳转的页面是我自己做的页面)请问要怎么修改代码??急急急25日需要知道答案
<form method="post" action="###" name="myform" onsubmit="checkpost()">
<label for="name">用户名:</label><input type="text" name="name" id="name" /><br />
<label for="pw">密码:</label><input type="password" name="pw" id="pw" /><br />
<input type="submit" value="提交" />
</form>
<script>
function checkpost(){
if(document.forms[0].name.value=="你要的用户名"&&document.forms[0].pw.value=="你要的密码"){
window.location="你要跳转的地址";
}else{
alert("用户名或密码不正确!")
return false;
}
}
</script>
你是单纯做前台的吗? 登录必须要请求一下后台 用“账号”和“密码”请求一下后台,后台会给你返回一个登录是否成功的状态,你根据这个状态才能跳转你想要的页面。
温馨提示:答案为网友推荐,仅供参考
第1个回答 2015-04-23
window.location="你要跳转的地址"; 这里少了个href,完全写法是这样的:window.location.href="xxx.html";本回答被提问者和网友采纳