ipgeocode.js: JSONP example with IP geocoding.

1.0
Ariya Hidayat 2010-12-28 00:09:50 -08:00
parent 88d6794065
commit d5b905a8ee
1 changed files with 14 additions and 0 deletions

14
examples/ipgeocode.js Normal file
View File

@ -0,0 +1,14 @@
// Give the estimated location based on the IP address.
cb = function (data) {
var loc = data.city;
if (data.region_name.length > 0)
loc = loc + ', ' + data.region_name;
phantom.log('IP address: ' + data.ip);
phantom.log('Estimated location: ' + loc);
phantom.exit();
};
var el = document.createElement('script');
el.src = 'http://freegeoip.net/json/?callback=cb';
document.body.appendChild(el);