Created
April 11, 2011 01:09
-
-
Save dalmaer/912919 to your computer and use it in GitHub Desktop.
Phantom.js example with location
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var cb = function (data) { | |
| var loc = data.city; | |
| if (data.region_name.length > 0) | |
| loc = loc + ', ' + data.region_name; | |
| console.log('IP address: ' + data.ip); | |
| console.log('Estimated location: ' + loc); | |
| phantom.exit(); | |
| }; | |
| var el = document.createElement('script'); | |
| el.src = 'http://freegeoip.net/json/?callback=cb'; | |
| document.body.appendChild(el); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment