Description:
We can get the IP address of the client
machine using JavaScript and JSON.
We are using third party service to get all
the client system details.
http://smart-ip.net/geoip-json - this third party service used for retrieving client details
and it will support JSON calls.
$.getJSON('http://smart-ip.net/geoip-json?callback=?',
function (data) {
});
data.host –
used to get system IP address.
data.city –
used to get client city.
data.timezone –
used to get client time zone.
data.countryName – used to get client country.
There is lot of third party services used to
get client system IP address and details like http://jsonip.appspot.com,
http://smart-ip.net
Example Program:
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
<script
type="text/javascript"
src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js">
</script>
<script
type="text/javascript">
$(document).ready(function () {
$("#btnGetIP").click(function () {
$.getJSON('http://smart-ip.net/geoip-json?callback=?', function (data) {
alert("My Ip:" + data.host + " My Country:" + data.countryName);
alert("My Timezone:" + data.timezone + " My City:" + data.city);
});
return
false;
});
});
</script>
</head>
<body>
<form
id="form1"
runat="server">
<div>
<asp:Button ID="btnGetIP" runat="server" Text="Button" />
</div>
</form>
</body>
</html>
In
the above program, I have specified a callback function which is executed when
the response is received and it displays the IP address with the alert box.
Find System IP Address and Location using Jquery,Get
Client IP address in Jquery , Get System IP address using Jquery, Get Client
Machine IP Address using Jquery, Get IP with Jquery, IP Address using jquery,
Jquery IP Address
0 comments:
Post a Comment