html中如何屏蔽ip地址,禁止某IP段访问网站?

成数国际_主机资讯 2023-09-17 20:29 编辑:admin 234阅读

把如下代码加入到<head>区域中  

<script LANGUAGE="Javascript">  

<!-- Begin  

netscape = (navigator.appName.indexOf("Netscape") != -1);  

version4 = (navigator.appVersion.indexOf("4.") != -1);  

if (netscape && version4) {   

ip = "" + java.net.InetAddress.getLocalHost().getHostAddress();   

if (ip.indexOf("235.12") >= -1)   

// 这是想要禁止访问的IP例如: 235.12.xxx.xxx   

{   

alert("You are not permitted to access this site.");   

history.go(-1);   

}  

}  

// End -->  

</script>

顶一下
(0)
0%
踩一下
(0)
0%
相关评论
我要评论
点击我更换图片