Brian Cryer's Web Resources

How to determine the nationality or location of a visitor

Internet Explorer supports the property 'navigator.userLanguage', which returns the operating system's language setting for the user. This can be used as a guide to the visitor's nationality or location.

However, be aware that:

  1. This property is non-standard and is not supported, for instance, by Netscape Navigator. For the likes of Netscape Navigator it will therefore be 'undefined'.
  2. If the visitor has not correctly specified their locale setting then it will return a misleading value - most PCs seem to come pre-installed with English-American as the default.

For a complete set of language codes that the property 'navigator.userLanguage' can return see http://msdn.microsoft.com/en-us/library/ms533052(VS.85).aspx. Common ones are reproduced here:

da Danish
de German (standard)
de-ch German (Switzerland)
en English
en-ca English, Canadian
en-gb English, British (Great Britain)
en-us English, American (United States). Windows default.
nl Dutch

The value of 'navigator.userLanguage' for your browser is: ' '

This implies that .

(If the nationality indicated is incorrect and you are using Internet Explorer then in all probability the locale settings on your PC are wrong. These are set under the 'Regional Settings' within 'Control Panel' on a PC running Windows.)

If all you want to do is to display a message appropriate to the visitors location then consider www.geobutton.com. They provide the facility to provide messages tailored to the geographic location of a visitor, such as:

This appears to use a reverse lookup on IP address to get the location (of the visitor's ISP). This works reasonably well in most cases but presumably becomes less accurate the further (geographically) the visitor is from the location of their ISP.

Other sites that provide a similar or related service include: