Solved

getting user country

Posted on 2002-04-09
3
190 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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article shows how to create and access 2-dimensional arrays in JavaScript.  It includes a tutorial in case you are just trying to "get your head wrapped around" the concept and we'll also look at some useful tips for more advanced programmers. …
Today I would like to talk about localizing (Internationalization) JavaScript applications. Introduction When creating an application that is going to be used by many people around the globe, it is important to remember that not everyone speak…
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…

773 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