技术教程
当前位置:首页 > 技术教程

利用API判断地区跳转,指定省份JS跳转代码

( 更新:10-18   加入收藏)
判断地区跳转代码,可以识别当前用户省份,市地区,然后跳转到指定的url上
如:北京用户跳转到bj.html ,上海用户自动跳转到sh.html

<script src="https://pv.sohu.com/cityjson?ie=utf-8" charset="GB2312" ></script>
<script type=text/javascript>
var _area=remote_ip_info.province;
if( _area=='北京'){
    window.location.href="/bj.html";
}else if( _area=='上海'){
    window.location.href="/sh.html";
}else{
    window.location.href="http://www.xxxx.com/";
}
</script>

相关阅读