1. 程式人生 > >web端ip定位

web端ip定位

int cat sin creat all tps call 新浪 asc

1/新浪定位

<script src="http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=js"></script>

var city = remote_ip_info[‘city‘];

alert(city);

2/百度ip定位

var _script = document.createElement(‘script‘);
_script.type = "text/javascript";
_key = ""; //百度地圖可以申請到
_script.src = "https://api.map.baidu.com/location/ip?ak=" + _key + "&coor=bd09ll&callback=citycallback"; //拼接URL
document.head.appendChild(_script);
function citycallback(data) {
console.log(data);

}

web端ip定位