我有一個使用javascript和if循環的密碼檢查。但是,當我輸入不是javascript的字符串時,不顯示警報。這是我的代碼。Javascript密碼檢查器
<script type = "text/javascript">
function password_prompt() {
var password = window.prompt("Please enter the correct password ", ""); //password = javascript
if (password == "javascript") {
var x = window.confirm("Please confirm you want to enter the webpage!");
if (x != 1) {
window.close();
window.open("https://www.google.com/");
}
if (password != "javascript") {
window.alert("You entered the wrong password! Page will now close!");
window.close();
window.open("about:blank");
}
}
}
</script>
縮進你的代碼,你會看到 – BeyelerStudios
OT:JavaScript的認證是一個壞主意... :) –
硬編碼密碼是一個壞主意 –