Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
459 views
in Technique[技术] by (71.8m points)

javascript - Very simple js static login

Just trying to get a very simple js login to validate a static username/password however cant seem to get it to work. Any help would be appreciated.

var checkLoginPass = function () {
    var login = document.getElementById("login").value;
    var pass = document.getElementById("password").value;
    if (login === "user123" && pass === "password1234") {
        window.location("http://www.google.com");
    }
    else {
        //do something else;
    }
};
<input type="text" id="login" required>
<input type="text" id="password" required>
<input type="button" id="goButton" onclick="checkLoginPass()" value="Log In"/>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use location.replace("http://www.google.com"); instead of window.location("http://www.google.com");


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...