VBscript中的疑问

来源:百度知道 编辑:UC知道 时间:2024/05/13 00:36:20
语句如下:
<html>
<body>
<script language="VBscript">
dim s,i
s=" "
mm="123456"
i=0
s=prompt("请输入密码")
do while not i=1
if s <> mm then
alert("抱歉,你输入的密码错误,你重输")
else
alert("密码正确")
end if
i=1
loop
</script>
</body>
</html>
但保存后打开,在弹出提示框不输入密码直接按取消也会提示正确?为什么会这样?

有人说i=1应该放在else里面,怎么放?
还有,当保存后打开时,输入错密码时,它提示完密码错误之后,不会接着循环再填..

这又为什么?
你们可以尝试着保存并打开看看

<html>
<body>
<script language="VBscript">
dim s,i
s=""
mm="123456"
i=0
do while not i=1
s=prompt("请输入密码")
if s=mm then
alert("密码正确")
i=1
else
alert("抱歉,你输入的密码错误,你重输")
end if
loop
</script>
</body>
</html>

楼上正确 不过我觉得让人试三次就成了