mercredi 15 juin 2016

Javascript Password Checker

I have a password check using javascript and an if loop. However, when I enter a string that is not javascript, no alert is displayed. Here is my code.

<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>

Aucun commentaire:

Enregistrer un commentaire