写一个检测进入html网页强制让你输入密码的程序
以下是一个简单的检测进入html网页强制让你输入密码的程序:
<!DOCTYPE html>
<html>
<head>
<title>Password Protection</title>
<script type="text/javascript">
function checkPassword() {
var password = document.getElementById("password").value;
if (password == "mypassword") {
window.location.href = "protected.html";
} else {
alert("Incorrect password! Please try again.");
}
}
</script>
</head>
<body>
<h1>Welcome to My Protected Page</h1>
<p>Please enter the password to access this page:</p>
<input type="password" id="password">
<button onclick="checkPassword()">Submit</button>
</body>
</html>
这个程序包含一个密码输入框和一个提交按钮。当用户输入密码并点击提交按钮时,程序会检查输入的密码是否正确。如果密码正确,程序会将用户重定向到另一个名为“protected.html”的页面。如果密码不正确,程序会弹出一个警告框,提醒用户输入正确的密码。
原文地址: https://www.cveoy.top/t/topic/bk9R 著作权归作者所有。请勿转载和采集!