Js gets a simple instance of the client's extranet IP


var wwip="";
  $(function(){
    $(document).ready( function() {
      $.getJSON( "http://smart-ip.net/geoip-json?callback=?",
        function(data){
          alert( data.host);
          wwip=data.host;
        }
      );
    });
  });

I’ve looked up a lot of information on this, but it doesn’t work. It works.

Example, js get local and external network IP address.

<script language="javascript" type="text/javascript">
//Get local IP
function GetLocalIPAddress()
{
var obj = null;
var rslt = "";
try
{
obj = new ActiveXObject("rcbdyctl.Setting");
rslt = obj.GetIPAddress;
obj = null;
}
catch(e)
{
alert("ErrInfoIS:"+e)
}
return rslt;
}
document.write(" your IP Is this: " + GetLocalIPAddress());
</script>

The above is the method of js to obtain the local IP address, let’s look at the example of js to obtain the external network IP address.

<script language="javascript">
//Get the outer network IP
xml=new ActiveXObject("Microsoft.XMLHTTP");
xml.open("GET","http://city.ip138.com/city0.asp",false);
xml.send();
kk=xml.ResponseText;
i=kk.indexOf("[");
ie=kk.indexOf("]");
ip=kk.substring(i+1,ie);
document.write("<span style='color:red;font-size:12;' cursor='hand'> your IP The address is :" + ip + "</span>");
</script>