-2

I want to find client's IP Address when accessing my app..How to find using javascript code..kindly provide help with sample code..I tried wit tis code but m not getting

function getip(json){ alert(json.ip); // alerts the ip address }
Annie
  • 160
  • 1
  • 2
  • 15
  • 1
    http://stackoverflow.com/questions/391979/get-client-ip-using-just-javascript check this – Anuj May 07 '13 at 06:01

2 Answers2

-1

You can't using ONLY JavaScript on it's own. You need to use a server side script ans call it using Ajax to perform this task.

For example in PHP script, you can do the following to get the client's ip address:

echo $_SERVER["REMOTE_ADDR"];

Next call this script using Ajax and display/use it in your page.

gopi1410
  • 6,567
  • 9
  • 41
  • 75
-1

At least there used to be a way using Java to do this, but Javascript alone cannot find a machines IP.

David Mårtensson
  • 7,550
  • 4
  • 31
  • 47
  • 1
    Please leave a comment on down vote to indicate the reason ;) Otherwise it does not help ether the one who wrote the answer or any one reading it :D. Also, if there is something wrong with my answer I am happy to delete it. The question asks for a pure Javascript solution client side which is not possible, the "duplicate" requires server side help which is not pure javascript either. – David Mårtensson Jul 29 '13 at 20:05