getting user country

hello i want to find out if someone that is surfing is from the UK. i want to know this, because then i decide to show a user a UK targeted banner.

i now use this:

if (navigator.browserLanguage.substr(3,2) == "gb") || (navigator.browserLanguage.substr(3,2) == "ie"))

but, i discovered that most users use a united states browser and therefore their value of the substr(3,2) evaluates to "us". i can't display it to "us" users only, because this is way too much.

i hope this can be done through javascript, as i don't want to pull allot of resources on the server.

thanks

marcek
LVL 2
marcel42Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
avnerConnect With a Mentor Commented:
try this

navigator.systemLanguage

navigator.userlanguage


0
 
andreifCommented:
I think it's better to check visitor's IP
Maybe you should think about CGI or PHP solution?
0
 
marcel42Author Commented:
navigator.userlanguage is the correct feature. in my post i mentioned that i was looking for a javascript solution. i think this will do. checking for IP is too advanced for my case. thanks for your help.
0
All Courses

From novice to tech pro — start learning today.