<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>js获取本地ip</title>
</head>
<body>
<script>
var xmlhttp;
if (window.XMLHttpRequest) {
xmlhttp = new XMLHttpRequest();
} else {
xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("get", "https://api.ipify.org?format=json", false);
xmlhttp.send();
var item = JSON.parse(xmlhttp.responseText);
console.log(item)
alert(item.ip)
</script>
</body>
</html>
通过js获取用户网络ip地址
最新推荐文章于 2024-07-03 11:22:03 发布