全部模版
新手必读
常见问题
更新日志
技术总结

屏蔽部分地区ip 实用JS代码

作者: admin2018-10-23


第一种 :但是要注意的是IP库能不能实时查询,不能打开就没办法判断,还会死循环,不停的判断

<script src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"  tppabs="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script> 
 
<form action="#" method="post">
<input type="hidden" name="ip" id="ip" value="" />
<SCRIPT> var province = remote_ip_info.province; var city = remote_ip_info.city; document.getElementById ("ip").value=city; </SCRIPT>
</form>
 
<script language="javascript">
var address = document.getElementById("ip").value;
if(address ==""){
document.write("访问出错")
}else if(address == "北京"|| address == "上海"|| address == "成都"){
 
window.location="index.htm"//审核页面
 
}else{
 
}
</script>
 
<script type="text/javascript">
function browserRedirect() { 
var sUserAgent= navigator.userAgent.toLowerCase(); 
var bIsIpad= sUserAgent.match(/ipad/i) == "ipad"; 
var bIsIphoneOs= sUserAgent.match(/iphone os/i) == "iphone os"; 
var bIsMidp= sUserAgent.match(/midp/i) == "midp"; 
var bIsUc7= sUserAgent.match(/rv:1.2.3.4/i) == "rv:1.2.3.4"; 
var bIsUc= sUserAgent.match(/ucweb/i) == "ucweb"; 
var bIsAndroid= sUserAgent.match(/android/i) == "android"; 
var bIsCE= sUserAgent.match(/windows ce/i) == "windows ce"; 
var bIsWM= sUserAgent.match(/windows mobile/i) == "windows mobile"; 
 
if (bIsIpad || bIsIphoneOs || bIsMidp || bIsUc7 || bIsUc || bIsAndroid || bIsCE || bIsWM) { 
 
} else { 
window.location.href="index.htm"; //审核页面
browserRedirect(); 
</script>


第二种 :注意的是IPJQ库能不能实时查询,不能打开就没办法判断,还会死循环,不停的判断。楼下屏蔽云南

<script src="https://ip.ws.126.net/ipquery"></script>
<script type="text/javascript">
      if(lo == "云南省")  
      {
        document.location.href = "index.php";
      }
  
  /*else if(lo == ("四川省")){
window.location="index.htm"//审核页面
 }*/
 
</script> 

Copyright © 2018-2020 贵阳网站建设 版权所有
QQ在线咨询