Solved

getting user country

Posted on 2002-04-09
3
194 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

The Ultimate Checklist to Optimize Your Website

Websites are getting bigger and complicated by the day. Video, images, custom fonts are all great for showcasing your product/service. But the price to pay in terms of reduced page load times and ultimately, decreased sales, can lead to some difficult decisions about what to cut.

Question has a verified solution.

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

Introduction HTML checkboxes provide the perfect way for a web developer to receive client input when the client's options might be none, one or many.  But the PHP code for processing the checkboxes can be confusing at first.  What if a checkbox is…
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…

705 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