JS浏览器获取本地IP的方法

转载来自:https://blog.csdn.net/qq_35855343/article/details/108706136

现在用的比较多的第三方免费开放接口一般是搜狐提供的接口:http://pv.sohu.com/cityjson?ie=utf-8。

所以通过script标签引入这个接口就可以了,这样还可以避免跨域的问题。
话不多说,上代码(亲测有效):

<!DOCTYPE html>
<html>
<head>
<title>get Ip and MAC!</title>
<meta http-equiv=Content-Type content="text/html; charset=gb2312">
</head>
<body>
<script src="http://pv.sohu.com/cityjson?ie=utf-8"></script>
<script type="text/javascript">
document.write(returnCitySN["cip"]+','+returnCitySN["cname"])
</script>
</body>
</html>
原文地址:https://www.cnblogs.com/Galesaur-wcy/p/14870407.html