javascript
<!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>