Get system IP Address and info using javascript / Jquery ~ Web CodeHelpers

Get system IP Address and info using javascript / Jquery

we used to work on User based applications all the time, we will have a requirement to capture the customer details  like

Customer IP Address
Customer Country Name
Customer City
Customer TimeZone
Customer Latitude
Customer Longitude

Rendering Live Demo using javascript in Process......



Here i am using javascript and  trying to get all the above details using a third party REST API

Third Party REST API : 

http://smart-ip.net/geoip-json


Using Javascript to fetch the customer system details

Javascript Code :
<script type="text/javascript">
    window.onload = function () {
        var script = document.createElement("script");
        script.type = "text/javascript";
        script.src = "http://smart-ip.net/geoip-json?callback=apiResponse";
        document.getElementsByTagName("head")[0].appendChild(script);
    };
    function apiResponse(response) {
        document.getElementById("ipaddress").innerHTML = "Your IP Address is : " + response.host;
        document.getElementById("language").innerHTML = "Your language : " + response.lang;
        document.getElementById("countryName").innerHTML = "Your Country Name : " + response.countryName;
        document.getElementById("city").innerHTML = "Your City is : " + response.city;
        document.getElementById("latitude").innerHTML = "Your latitude is : " + response.latitude;
        document.getElementById("longitude").innerHTML = "Your longitude is : " + response.longitude;
        document.getElementById("timezone").innerHTML = "Your timezone is : " + response.timezone;
    }
</script>


Complete HTML Code :

<!doctype html>
<html>
<head>
<title>System IP Address</title>
<script type="text/javascript">
   window.onload = function () {
       var script = document.createElement("script");
       script.type = "text/javascript";
       script.src = "http://smart-ip.net/geoip-json?callback=apiResponse";
       document.getElementsByTagName("head")[0].appendChild(script);
   };
   function apiResponse(response) {
       document.getElementById("ipaddress").innerHTML = "Your IP Address is : " + response.host;
       document.getElementById("language").innerHTML = "Your language : " + response.lang;
       document.getElementById("countryName").innerHTML = "Your Country Name : " + response.countryName;
       document.getElementById("city").innerHTML = "Your City is : " + response.city;
       document.getElementById("latitude").innerHTML = "Your latitude is : " + response.latitude;
       document.getElementById("longitude").innerHTML = "Your longitude is : " + response.longitude;
       document.getElementById("timezone").innerHTML = "Your timezone is : " + response.timezone;
   }
</script>
</head>
<body>
<div id="countryName" style=" color: #5C00FF; font-size: 18px;"></div>
<div id="city" style=" color: #5C00FF; font-size: 18px;"></div>
<div id="timezone" style=" color: #5C00FF; font-size: 18px;"></div>
<div id="ipaddress" style=" color: #5C00FF; font-size: 18px;"></div>
<div id="language" style=" color: #5C00FF; font-size: 18px;"></div>
<div id="latitude" style=" color: #5C00FF; font-size: 18px;"></div>
<div id="longitude" style=" color: #5C00FF; font-size: 18px;"></div>
</body>
</html>




What is my ip address

7 comments :

  1. This comment has been removed by a blog administrator.

    ReplyDelete
  2. dont visit this site...complete failre

    ReplyDelete
  3. This comment has been removed by the author.

    ReplyDelete
  4. waste of time . if u need answer for this question contact me....at sriramjan16@gmail.com

    ReplyDelete

Subscribe updates via Email