Jquery - Get client computer IP address
By [)ia6l0 iii
We can use the appspot IPAddress provider server , that returns the ip of the requesting client in the Json format. Use the callback function and retrieve the IP Address.
If you hit the following url, you will find the json response.
http://jsonip.appspot.com/
{"ip": "111.22.333.444", "address":"111.22.333.444"}
The following JQuery function retrieves the IP on a button click.
$(function() {
$('btn').click(function()
{
$.getJSON("http://jsonip.appspot.com?callback=?",function(jsonResult){
alert( "IP Adress = " + jsonResult.ip);
});
});
Related FAQs
You need to define the Javascript file extension as Static content and enable the compression.
You can use the RemoveClass method to remove the style on an element.
You can handle errors in ASP.Net Ajax web pages using some Javascript code.
You can create short url's using the Google URL Shortening API
You can use Jquery plugin to hightlight text on a web page
Use the each method to loop thru the element collection. The following example loops through the img elements.
Jquery - Get client computer IP address (3702 Views)