html文件访问密码多少?
关于HTML设置访问密码。
如果你要设置访问密码恐怕要使用sublime_text了
先把这些东西加上:
<html>
<script>
然后开始写代码:
先辨别密码登录正确的情况:
复制代码
function check(){
var name=document.getElementById("name").value;
var pass=document.getElementById("pass").value;
if(name=="cdssxxx" && pass=="2372535103"){
alert("登入成功");
window.document.f.action="链接的网址";
window.document.f.submit();
}
复制代码
然后用一个else来连接(判断密码输入错误):
else{
alert("用户名或密码错误");
}
这段很简单,就不用细说了!!
接下来,搭建一个文本框,来装入输入的代码,(要用input):
复制代码
<form name="f" action="">
<center>用户名:<INPUT TYPE="text" NAME="" id="name"><br></center>
<center>密码:<INPUT TYPE="password" NAME="" id="pass"><br></center>
<center><INPUT TYPE="button" value="登入" onclick="check()"><INPUT TYPE="reset" value="重置"></center>
</form>
复制代码
这样就可以啦!!!
最后献上完整的代码:
复制代码
<script>
function check(){
var name=document.getElementById("name").value;
var pass=document.getElementById("pass").value;
if(name=="cdssxxx" && pass=="2372535103"){
alert("登入成功");
window.document.f.action="你的链接网址";
window.document.f.submit();
}else{
alert("用户名或密码错误");
}
}
</script>
<form name="f" action="">
<center>用户名:<INPUT TYPE="text" NAME="" id="name"><br></center>
<center>密码:<INPUT TYPE="password" NAME="" id="pass"><br></center>
<center><INPUT TYPE="button" value="登入" onclick="check()"><INPUT TYPE="reset" value="重置"></center>
</form>
Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有