-4

I have a div with an img tag. This img tag should display the visitors country flag. However, im getting no progress in trying to find a solution.

A first thought was maybe those things are possible via server side and php, but then I again there must be a simple jquery method.

I am not asking anyone to code a solution! I just want to know what methods are there for simple tasks like mine? I also tried to look for libraries that do that without the so called "JSON".

Steve
  • 111
  • 8
  • Yes obviously , you can detect the visitors IP and detect the location. Thier are many APIS for this, all are not 100% accurate. https://www.maxmind.com/en/home – Dimag Kharab Nov 10 '14 at 13:47

3 Answers3

1

You can do that using the geolocation API. But the user has to allow the location detection for it to work.

https://developer.mozilla.org/en-US/docs/Web/API/Geolocation/Using_geolocation

1

HTML5 provides a Geolocation API, maybe you can try to use that.

https://developers.google.com/maps/documentation/javascript/examples/map-geolocation?hl=de

Google (and maybe other too) offers a free API to transform the location to for example the country.

Jonathan
  • 3,614
  • 3
  • 21
  • 30
0

Unfortunately this is a bit of a link only answer, but you have a similar question here:

Display Country Flag by IP

The answer itself refers to this tutoprial:

http://roshanbh.com.np/2008/07/getting-country-city-name-from-ip-address-in-php.html

This answer also looks very promising:

How can I get user's country flag on my site

According to this link you can also use $_SERVER['HTTP_ACCEPT_LANGUAGE'] to get the language, rather than using a third part service.

Display Flag By Country Script

Community
  • 1
  • 1
The Humble Rat
  • 4,586
  • 6
  • 39
  • 73