0

I am creating a Javascript for my users and i am trying to make it as light weight as possible.

Because of this i am not using any outside liberay (not even JQuery) if possible i want to keep it that way.

So my question is: Is it possible to get a visitors IP address without the use of External calls or lib.

By external calls i am refering to:

Ajax, google Jsapi, and others

Note that i have been looking at the answer to this question get client ip using just javascript However this is not what i am looking as it goes outside of the current page to collect its information.

Community
  • 1
  • 1
Marc
  • 483
  • 3
  • 14
  • 22

2 Answers2

3

No. This information is not provided by the browser to the scripts running inside web pages, so there is no way to access it without interogating a remote server (external call).

Tibos
  • 27,507
  • 4
  • 50
  • 64
  • Okay.. what would you suggest to be the most light weight solution? – Marc Sep 12 '13 at 07:55
  • Just try $_SERVER["REMOTE_ADDR"] in PHP – David Sep 12 '13 at 07:56
  • I think this answer is pretty lightweight (because you don't need to set up the server), but you will have to turn the code to pure JS if you don't want to use JQuery: http://stackoverflow.com/a/17808050/1669279 Anyway, there are quite a few similar questions on stackoverflow and you might find a better suited answer there. – Tibos Sep 12 '13 at 07:58
0

If you have the latest java

function myIP()
{ 
    var yip2=java.net.InetAddress.getLocalHost();   
    var yip=yip2.getHostAddress();
    return yip;
}