在 HTML 中,可以使用 JavaScript 来实现多个密码访问不同页面的功能。下面是一个示例代码:

<!DOCTYPE html>
<html>
<head>
    <title>Password Protected Pages</title>
    <script>
        function checkPassword() {
            var password = document.getElementById('password').value;
            
            // 根据密码不同跳转到不同的页面
            if (password === 'password1') {
                window.location.href = 'page1.html';
            } else if (password === 'password2') {
                window.location.href = 'page2.html';
            } else if (password === 'password3') {
                window.location.href = 'page3.html';
            } else {
                alert('密码错误,请重新输入!');
            }
        }
    </script>
</head>
<body>
    <h1>Password Protected Pages</h1>
    
    <label for='password'>密码:</label>
    <input type='password' id='password'>
    <button onclick='checkPassword()'>进入页面</button>
</body>
</html>

在上面的代码中,使用 <input type='password'> 元素来接收密码输入,然后通过 JavaScript 的 checkPassword() 函数来判断密码是否正确,并根据不同的密码跳转到不同的页面。如果密码不正确,会弹出一个提示框提示用户重新输入密码。

HTML 多密码访问不同页面 - JavaScript 实现

原文地址: http://www.cveoy.top/t/topic/pbY1 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录