百度空间 | 百度首页 
 
查看文章
 
禁止IP访问的JS代码
2008年03月19日 星期三 下午 04:33

要完成此效果把如下代码加入到<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)
 
最近读者:
 
网友评论:
发表评论:
姓 名:
网址或邮箱: (选填)
内 容:
验证码: 请点击后输入四位验证码,字母不区分大小写
      

     

©2009 Baidu