单个html5页面要实现加个密码才能访问,可以用js来控制。代码加在<head>插入下面代码</head>代码如下:

<script languange="JavaScript">
        var password=""
        password=prompt('请输入密码(本网站需输入密码才可以进入):','');
        function custom_close()
        {
            window.opener=null;
            window.open('','_self');
            window.close();        
        }   
        if  (password !='123456')
            {alert("密码不正确,无法进入本站!!!")
            
            custom_close();            
            alert("即将打开百度")//加这一段是为了避免有些浏览器不支持关闭浏览器的js ,所以请求跳转到一个新页面!
            window.location.href='http://www.baidu.com';
            }
</script>

 

相关文章:

  • 2021-12-08
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-12-16
  • 2021-12-04
  • 2022-12-23
  • 2022-12-23
  • 2021-12-24
  • 2022-01-13
  • 2021-06-12
相关资源
相似解决方案