Using jQuery, this line will display your user’s country code.
$.getJSON('https://freegeoip.net/json/', function(result) {
alert(result.country_code);
});
More Related Contents:
- JavaScript for detecting browser language preference [duplicate]
- How to determine user’s locale within browser?
- navigator.geolocation.getCurrentPosition sometimes works sometimes doesn’t
- How to get visitor’s location (i.e. country) using geolocation?
- Get city name using geolocation [duplicate]
- getCurrentPosition() and watchPosition() are deprecated on insecure origins
- Get GPS location from the web browser
- How to get the exact local time of client?
- Determine timezone from latitude/longitude without using web services like Geonames.org
- toRad() Javascript function throwing error
- How do I localize the jQuery UI Datepicker?
- Mercator longitude and latitude calculations to x and y on a cropped map (of the UK)
- Get country from latitude longitude
- Is there a way to reverse the formatting by Intl.NumberFormat in JavaScript
- Localize Strings in Javascript
- Change format of md-datepicker in Angular Material with momentjs
- Geolocation API on the iPhone
- How to find my distance to a known location in JavaScript
- How can I find a user’s country using HTML5 geolocation?
- How to get the formatted address from a dragged marker in Google Version Maps
- ask for geolocation permission again if it was denied
- Which Devices Support Javascript Geolocation via navigator.geolocation?
- unable to cope with the asynchronous nature of navigator.geolocation
- Converting latitude and longitude to decimal values
- How to replace numbers in body to Persian numbers?
- Android Phonegap – How to Open Native Google Maps Application
- Geolocation closest location(lat, long) from my position
- contenteditable change events
- How should I call 3 functions in order to execute them one after the other?
- How to Use Sockets in JavaScript\HTML? [closed]