Get an IP address with javascript without using ajax, jquery or another library

advertisements

I want get the ip address of my clients, but i only want to use pure Javascript without another library

I searched in the internet but i can't found a way to do it, I'm a student so, I have no choise, I can use only JavaScript

I found this, but it doesn't work

function myIP(){ var vi="uses java to get the users local ip number";
        var yip2=java.net.InetAddress.getLocalHost();
        var yip=yip2.getHostAddress();
      return yip;
    }


You could use telize, a third party, and make a jsonp request:

<script type="application/javascript">
function getip(json){
    document.write("My IP address is : ", json.ip);
}
</script>

<script type="application/javascript" src="http://www.telize.com/jsonip?callback=getip"></script>