How to check the province and city of the user's IP address in js
1. Import the js file
<script src="https://pv.sohu.com/cityjson?ie=utf-8"></script>
<script src="https://ip.ws.126.net/ipquery"></script>
2. js judges the city code of the province
<script src="https://code.jquery.com/jquery-3.3.1.min.js"></script>
<script>
var iPAddress = "", iPAttach = "";//IP地址,IP归属地
GetIPAll();
//获取IP地址,IP归属地
function GetIPAll() {
iPAddress = returnCitySN["cip"];//IP地址:
iPAttach = localAddress["province"] + localAddress["city"];//IP归属地
}
alert(iPAttach);
</script>