Home > Uncategorized > IP info popup in Javascript

IP info popup in Javascript

Here’s a code snippet using Bootstrap / Jquery / bootbox / telize to provide info on an IP address via Javacript / JSONP

<html>
<head>
https://code.jquery.com/jquery-1.11.3.min.js
https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js
https://cdnjs.cloudflare.com/ajax/libs/bootbox.js/4.4.0/bootbox.min.js
<link href=”https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css&#8221; rel=”stylesheet”>
</head>
<body>
<span class=”ip”>64.233.167.106</span>
</body>

$(init);
function init()
{
$(“.ip”).bind(“click”,ip_click);
}
function ip_click()
{
var ip = $(this).text();
var strUrl = “http://www.telize.com/geoip/&#8221; + ip + “?callback=getgeoip”;
$.ajax({
url: strUrl,
jsonp: “getgeoip”,
dataType: “jsonp”,
});
}
function getgeoip(data)
{
var strHtml = “IP: ” + data.ip + “
“;
strHtml += “” + data.city + “, ” + data.region + “, ” + data.country + “
“;
strHtml += “ISP: ” + data.isp + ““;
bootbox.alert(strHtml);
}

</html>

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: