1. 首页
  2. JS屏蔽指定地区用户访客浏览访问网站 指定地区访问网站页面跳转

JS屏蔽指定地区用户访客浏览访问网站 指定地区访问网站页面跳转

某些特殊情况下网站可能需要屏蔽部分地区的访问

将以下代码添加到网站模板即可使用

页面加入js代码(以屏蔽北京为例)

<script type="text/javascript" src="https://ip.useragentinfo.com/json" rel="external nofollow"  charset="gb2312"></script><script type="text/javascript">var city = returnCitySN['cname'];if(city.indexOf('这里填写所屏蔽的地区名称比如北京') != -1) {   window.location.href = "这里替换为你需要跳转的页面网址"  }</script>

2023年3月14日新增几个IP接口:

IP信息网 https://ip.useragentinfo.com/json?ip=14.106.140.11
太平洋的 http://whois.pconline.com.cn/ipJson.jsp?ip=14.106.140.11&json=true