简体   繁体   English

有没有办法使用 Chrome 使用 JSP 获取真正的 Ip 或 IPV6 地址

[英]Is there a ways to Get real Ip or IPV6 Address using Chrome using JSP

I have a question on the IP address.我对 IP 地址有疑问。 I can get my IP address however it is not the Public or IPV6 that I need for IP Stack to render my location properly.我可以获得我的 IP 地址,但它不是我需要 IP 堆栈正确呈现我的位置的公共或 IPV6。 Furthermore, I have the below code and is pulling the IP address and can look it up however is the ISP or not with in the 30 miles of my location.此外,我有下面的代码,并且正在提取 IP 地址,并且可以查找它,但是我所在位置 30 英里内是否有 ISP。 I have reached for something in JSP that will help by either making a call and reading it back with public but not getting anything worth using.我已经在 JSP 中找到了一些东西,这将有助于通过拨打电话并将其与公众阅读但没有得到任何值得使用的东西。 I really would like to find the IPV6我真的很想找到IPV6

the IP I get is not the public or showing my location, Thank you for your help in advance我得到的 IP 不是公开的或显示我的位置,谢谢您提前帮助

Code: (Very Simple)代码:(非常简单)

<!DOCTYPE html>
<html>
 
<head>
    <title>Getting Clients IP</title>
    <style>
    p, h1 {
        color: green;
    }
    </style>
  
    <script src=
"https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js">
    </script>
     
      <script>
     

                
    $.getJSON("https://api.ipify.org?format=json", function(data) {
         
        // Setting text of element P with id gfg
        $("#gfg").html(data.ip);
    })
    </script>
</head>
 
<body>
    <center>
        <h1>Get Local IP Address</h1>
        <h3>Public IP Address of user is:</h3>
        <p id="gfg"></p>
 
    </center>
</body>
 
</html>

My issues were that I need to get an IP to use Geolocation however I was able to just go directly to Location using the below test page (this will be incorporated in to a large page and most likely streamlines but can see the process.我的问题是我需要获得一个 IP 才能使用地理定位,但是我能够使用下面的测试页面直接将 go 直接定位到位置(这将被合并到一个大页面中,并且很可能简化,但可以看到该过程。
Thank you for all your help and questions.感谢您的所有帮助和问题。

CODE代码

<!DOCTYPE html>
<html>
<body>

<p>Click the button to get your coordinates.</p>

<button onclick="getLocation()">Try It</button>

<p id="demo"></p>

<script>
var x = document.getElementById("demo");

function getLocation() {
  if (navigator.geolocation) {
    navigator.geolocation.getCurrentPosition(showPosition);
  } else { 
    x.innerHTML = "Geolocation is not supported by this browser.";
  }
}

function showPosition(position) {
  x.innerHTML = "Latitude: " + position.coords.latitude + 
  "<br>Longitude: " + position.coords.longitude;
}
</script>

</body>
</html>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM