输入密码错误页面关闭 代码

来源:百度知道 编辑:UC知道 时间:2024/05/24 05:55:27
已经在网页中加入代码。不过是输入错误后退的,,请各位高手帮忙改下,让它输入错误就直接关闭打开的页面,谢谢了
<SCRIPT LANGUAGE="JavaScript">
function password() {
var testV = 1;
var pass1 = prompt('请输入密码(密码是welcome):','');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1 == "welcome") {
alert('密码正确!');
break;
}
testV+=1;
var pass1 =
prompt('密码错误!请重新输入:');
}
if (pass1!="password" & testV ==3)
history.go(-1);
return " ";
}
document.write(password());
</SCRIPT>

<SCRIPT LANGUAGE="JavaScript">
function password() {
var testV = 1;
var pass1 = prompt('请输入密码(密码是welcome):','');
while (testV < 3) {
if (!pass1)
history.go(-1);
if (pass1 == "welcome") {
alert('密码正确!');
break;
}
testV+=1;
var pass1 =
prompt('密码错误!请重新输入:');
}
if (pass1!="password" & testV ==3)
windows.close();
}
document.write(password());
</SCRIPT>