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” 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/” + 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>