Solved

getting user country

Posted on 2002-04-09
3
187 Views
Last Modified: 2008-03-17
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
0
Comment
Question by:marcel42
3 Comments
 
LVL 6

Expert Comment

by:andreif
ID: 6930550
I think it's better to check visitor's IP
Maybe you should think about CGI or PHP solution?
0
 
LVL 14

Accepted Solution

by:
avner earned 75 total points
ID: 6930571
try this

navigator.systemLanguage

navigator.userlanguage


0
 
LVL 2

Author Comment

by:marcel42
ID: 6930837
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

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

When you need to keep track of a simple list of numbers or strings, the Array object is your most direct tool.  As we saw in my earlier EE Article (http://www.experts-exchange.com/A_3488.html), typical array handling might look like this: (CODE) B…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now