Solved

getting user country

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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

In this article, we'll look how to sort an Array in JavaScript, including the more advanced techniques of sorting a collection of records either ascending or descending on two or more fields. Basic Sorting of Arrays First, let's look at the …
Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
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…

740 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