0

I have created a chrome application which acts like a server.For that i need to find local ip address in javascript.I tried below code.but i am unable to find ip address of server.Is there any other possible way to find ip address in 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>
Adhika
  • 1
  • 1
  • 1
  • 1
    possible duplicate of [Can I lookup the IP address of a hostname from javascript?](http://stackoverflow.com/questions/102605/can-i-lookup-the-ip-address-of-a-hostname-from-javascript) – Swaraj Giri Sep 23 '15 at 09:42

1 Answers1

0

If you are looking for a client's public facing IP, as far as I'm aware, this question has been asked before with the conclusion that, at present, it is not currently possible.

Example: Retrieve Public IP From Google Web App

However, if you are looking for their local IP - this has also been asked before with some pretty interesting results.

Example: Get Local IP of a device in chrome extension

In the top answer to that question, they propose that this is possible using the WebRTC API. I'd suggest looking in to that answer to see if it helps with your situation.

Community
  • 1
  • 1
Lewis
  • 3,479
  • 25
  • 40