我正在尝试制作一个"ENTER"按钮,在您提交密码后将您带到网站上的隐藏页面



该网站是使用GoDaddy网站生成器创建的,因此我对此的选择有限,但我只想创建对其中一个页面的仅限密码访问(每个人都可以是相同的密码(,并带有密码输入字段和提交按钮。

我是一个完全的初学者,正在努力自学(可能很明显!(。我用很少的知识拼凑出了以下内容,显然我做错了什么。

function passWord() {

var testV = 1;
var pass1 = prompt('Please Enter Your Password', '');

while (testV < 3) {
if (!pass1)
history.go(-1);

if (pass1.toLowerCase() == "mypassword") {
window.open('http://www.website.com/webpage.html');
break;
}

testV += 1;

var pass1 =
prompt('Access Denied - Password Incorrect, Please Try Again.', '');

}

if (pass1.toLowerCase() != "password" & testV == 3)
history.go(-1);

return " ";
}
input {
background-color: #000000;
border: none;
color: white;
padding: 15px 32px;
text-align: center;
text-decoration: none;
display: block;
font-size: 16px;
margin: auto;
cursor: pointer;
}

/* Style the submit button */
input[type=submit] {
background-color: #000000;
color: white;
}

/* The message box is shown when the user clicks on the password field */
#message {
display: none;
background: #f1f1f1;
color: #000;
position: relative;
padding: 20px;
margin-top: 10px;
}
#message p {
padding: 10px 35px;
font-size: 18px;
}
<div class="container">
<form action="/action_page.php">
<input type="password" id="pwd" name="pwd" <br><br>
<input type="submit" value="SUBMIT">
</form>
</div>

尝试使用API位置https://developer.mozilla.org/en-US/docs/Web/API/Window/location

更改->window.open('http://www.website.com/webpage.html');

location.assign("http://www.website.com/webpage.html")

最新更新