简体   繁体   中英

JavaScript var password error

i keep putting in this code, but every time i try it out, it lets me in whether or not it's the right password, rather than only letting me in if it's the right password. Can someone help with this issue?

<script language="JavaScript">
<!--hide
var password;
var pass1="password1";
var pass2="password2";
password=prompt('Enter Password To View The Page',' ')
if (password==pass1||pass2)
alert('Correct password, Welcome.');
else{ 
window.location="http://www.google.com";
}

</script>
if (password==pass1|| password == pass2){
    alert('Correct password, Welcome.');
}
else{ 
    window.location="http://www.google.com";
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM