<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>登录</title>
<link type="text/css" href="./css/1-1.css" rel="stylesheet"/>
<script type="text/javascript">
function login(){
var username = document.getElementById("name").value;
var password = document.getElementById("pass").value;
if(username=="123456" && password=="123456"){
alert("登录成功");
window.location = "http://www.baidu.com";
return false;
}
else{
alert("账号或密码错误");
window.location.href= "登录界面.html";
return false;
}
}
</script>
</head>
<div class="biaoti">
<h1 class="biaoti-1">欢迎来到登陆界面</h1>
<input class="box-2" id="name" type="text" placeholder="用户名">
<input class="box-2" id="pass" type="password" placeholder="密码">
<input class="box-3" name="chkBth" id="chkBth" type="button" value="登录" >
<div class="mya">
<a href="主文件/zh.html">忘记密码</a>
<a href="主文件/zc.html">注册</a>
</div>
</div>
</body>
</html>
![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/019834695736126.png "#left")
HTML用function login输入了账号密码,登录按钮不能实现跳转
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
2条回答 默认 最新
- mrjimin 2021-11-23 13:25关注
写了函数,但是登录按钮没加触发事件的方法,加上不就行了
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报
悬赏问题
- ¥100 set_link_state
- ¥15 虚幻5 UE美术毛发渲染
- ¥15 CVRP 图论 物流运输优化
- ¥15 Tableau online 嵌入ppt失败
- ¥100 支付宝网页转账系统不识别账号
- ¥15 基于单片机的靶位控制系统
- ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
- ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
- ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
- ¥15 手机接入宽带网线,如何释放宽带全部速度