编程爱好者之家
一:先引用js
<script src="https://ip.ws.126.net/ipquery"></script>
此js的返回结果为如下示例
var lo="上海市", lc="上海市"; var localAddress={city:"上海市", province:"上海市"}
二:判断地区并做相应操作
var province=localAddress.province; var city=localAddress.city; if(province.indexOf('上海') != -1){ window.location.href="https://www.codelovers.cn/"; }