ipgeocode.js 426 B

1234567891011121314
  1. // Give the estimated location based on the IP address.
  2. cb = function (data) {
  3. var loc = data.city;
  4. if (data.region_name.length > 0)
  5. loc = loc + ', ' + data.region_name;
  6. console.log('IP address: ' + data.ip);
  7. console.log('Estimated location: ' + loc);
  8. phantom.exit();
  9. };
  10. var el = document.createElement('script');
  11. el.src = 'http://freegeoip.net/json/?callback=cb';
  12. document.body.appendChild(el);