javascript prompt判断输入密码正确
<html><head><title>过渡页面</title><scriptlanguage="JavaScript">functionpassword(){vartes...
<html>
<head>
<title>过渡页面</title>
<script language="JavaScript">
function password() {
var testV = 1;
var pass1 = prompt('请输入密码:','');
while (testV < 3)
{
if pass1 == "password" then
{ //password为密码
alert('登陆成功!');
window.location="passed.htm"; //正确链接的URL.html
break;
}
testV+=1;
var pass1 = prompt('密码不对,请重新输入');
}
if (pass1!="password" and testV ==3) then
location.href="about:blank";
}
document.write(password());
</script>
</head>
<body>
</body>
</html>
哪里有小问题?我试了很久没发现 展开
<head>
<title>过渡页面</title>
<script language="JavaScript">
function password() {
var testV = 1;
var pass1 = prompt('请输入密码:','');
while (testV < 3)
{
if pass1 == "password" then
{ //password为密码
alert('登陆成功!');
window.location="passed.htm"; //正确链接的URL.html
break;
}
testV+=1;
var pass1 = prompt('密码不对,请重新输入');
}
if (pass1!="password" and testV ==3) then
location.href="about:blank";
}
document.write(password());
</script>
</head>
<body>
</body>
</html>
哪里有小问题?我试了很久没发现 展开
3个回答
展开全部
你好,我给你修改了两处if的地方,能正确运行了
if pass1 == "password" then 改成 if(pass1 == "password")
if (pass1!="password" and testV ==3) then 改成 if (pass1!="password" && testV ==3)
最后完整的代码是
<html>
<head>
<title>过渡页面</title>
<script language="JavaScript">
function password() {
var testV = 1;
var pass1 = prompt('请输入密码:','');
while (testV < 3)
{
if(pass1 == "password")
{ //password为密码
alert('登陆成功!');
window.location="passed.htm"; //正确链接的URL.html
break;
}
testV+=1;
var pass1 = prompt('密码不对,请重新输入');
}
if (pass1!="password" && testV ==3)
location.href="about:blank";
}
document.write(password());
</script>
</head>
<body>
</body>
</html>
if pass1 == "password" then 改成 if(pass1 == "password")
if (pass1!="password" and testV ==3) then 改成 if (pass1!="password" && testV ==3)
最后完整的代码是
<html>
<head>
<title>过渡页面</title>
<script language="JavaScript">
function password() {
var testV = 1;
var pass1 = prompt('请输入密码:','');
while (testV < 3)
{
if(pass1 == "password")
{ //password为密码
alert('登陆成功!');
window.location="passed.htm"; //正确链接的URL.html
break;
}
testV+=1;
var pass1 = prompt('密码不对,请重新输入');
}
if (pass1!="password" && testV ==3)
location.href="about:blank";
}
document.write(password());
</script>
</head>
<body>
</body>
</html>
展开全部
代码中if判断书写有误,建议按照书写规范来写,应写成if(){},且if判断语句里面没有then。
1、if pass1 == "password" then 的判断语句修改为
if(pass1 == "password"){
//password为密码
alert('登陆成功!');
window.location="passed.htm"; //正确链接的URL.html
break;
}
2、if (pass1!="password" and testV ==3) then 的判断语句修改为 :
if (pass1!="password" && testV ==3){location.href="about:blank";}
1、if pass1 == "password" then 的判断语句修改为
if(pass1 == "password"){
//password为密码
alert('登陆成功!');
window.location="passed.htm"; //正确链接的URL.html
break;
}
2、if (pass1!="password" and testV ==3) then 的判断语句修改为 :
if (pass1!="password" && testV ==3){location.href="about:blank";}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2011-10-28
展开全部
if then?这是javascript的语法吗?成VB了。打开浏览器的调试工具,看报什么错
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询