輸入密碼(方法1)
例子(預設密碼:tvbnow)
輸入密碼錯誤三次後,
會回到上一頁<!-- begin -->
<SCRIPT LANGUAGE="JavaScript">
function password() {
var testV = 1;
//在引號內設置密碼提示
var pass1 = prompt("please enter the password.");
while (testV < 3) {
if (!pass1)
history.go(-1);
//在引號內設置密碼
if (pass1 == "tvbnow") {
//在引號內設置輸入正確後的顯示訊息
alert("yeah! welcome to TVBNOW.");
break;
}
testV+=1;
var pass1 =
//在引號內設置輸入錯誤後的顯示訊息
prompt("please enter the password again.");
}
if (pass1!="password" & testV ==3)
history.go(-1);
return " ";
}
document.write(password());
</SCRIPT>
<!-- end --> |