简体   繁体   English

网站密码在移动设备上不起作用

[英]Website password does not work on mobile

I've protected my website using a password (I don't really need a "real" protection, it's just a small save the date website, no big deal, just don't want people to mind my business ;) ) 我已经使用密码保护了我的网站(我真的不需要“真正的”保护,它只是保存日期的网站中的一小部分,没什么大不了的,只是不想让人们介意我的生意;))

But the code I've used does not seem to work on mobile version. 但是我使用的代码似乎不适用于移动版本。 Whenever I enter the password I chose, I always get the error message of wrong password, even if it's correct. 每当我输入选择的密码时,即使密码正确,也总是会收到错误密码的错误消息。 Any idea of how can I possibly solve this? 关于如何解决这个问题的任何想法?

var password = "please";
var x = prompt("Enter in the password "," ");
if (x.toLowerCase() == password) {
  alert("Come right in \n \n You've entered in the right password");
  window.location = "index.htm";
}
else {
  window.location = "bad.htm";
}

Please look at your line: 请查看您的行:

var x = prompt("Enter in the password "," ");

Your second parameter is adding a blank space before your answer " ". 您的第二个参数是在答案“”之前添加一个空格。 You should use the blank parameter "". 您应该使用空白参数“”。

For example if you type your password: please. 例如,如果您输入密码:Please。 Instead of comparing "please" to "please" it will wrongly compare "please" to " please". 与其将“请”与“请”进行比较,不如将“请”与“请”进行比较。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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