mirror of https://github.com/vitalif/phantomjs
ipgeocode.js: JSONP example with IP geocoding.
parent
88d6794065
commit
d5b905a8ee
|
@ -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);
|
Loading…
Reference in New Issue