簡體   English   中英

如何在JavaScript中查找服務器IP地址

[英]How to find server ip address in javascript

我創建了一個像服務器一樣的chrome應用程序。為此,我需要在javascript中找到本地ip地址。我嘗試了下面的代碼。但是我找不到服務器的ip地址。在javascript中。

<script type="text/javascript">
 var userip;
</script>
  ...
  <script type="text/javascript" src="https://l2.io/ip.js?var=userip">       </script>
   ...
   <script type="text/javascript">
  document.write("Your IP is :", userip);
  </script>

據我所知,如果您正在尋找客戶的面向公眾的IP,那么此問題已被問過,得出的結論是目前尚不可能。

示例: 從Google Web App檢索公共IP

但是,如果您正在尋找他們的本地IP-以前也有人問過它,但結果卻很有趣。

示例: 以chrome擴展名獲取設備的本地IP

在該問題的最佳答案中,他們建議使用WebRTC API可以做到這一點。 我建議您查看該答案,看看是否對您的情況有所幫助。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM