Re: Locale in JavaScript?
- From: RobG <rgqld@xxxxxxxxxxxx>
- Date: 25 Apr 2007 22:59:37 -0700
On Apr 25, 8:11 pm, Simon Brooke <s...@xxxxxxxxxxxxxx> wrote:
in message <1177473080.796542.163...@xxxxxxxxxxxxxxxxxxxxxxxxxxx>,
jhurs...@xxxxxxxxx ('jhurs...@xxxxxxxxx') wrote:
On Apr 24, 3:13 am, Simon Brooke <s...@xxxxxxxxxxxxxx> wrote:
But going through the documentation I can't find any reliable way of
getting the locale in JavaScript. Am I missing something, or is this
impossible? If it's impossible, why is it impossible?
What do you mean by "locale"? Do you mean timezone? Country?
Approximate geographic location to within say 1,000 km?
Why is it impossible? Because there is no standard that says it must
be available and browser developers have, in general, considered it
unsuitable to include as an extension. As for why they consider it
unsuitable, you'd better ask them.
To determine the local in JavaScript use:
navigator.language for netscape flavored browsers
navigator.browserLanguage for IE
H'mmm... nasty. No single portable way? Still, better than nothing...
thanks.
Yes, nasty advice - using the language setting is worse than nothing.
Mine says "en-GB", but if you think that means I am in Great Britain,
you're very wrong. My timezone is GMT+10.
If you want to find out where (approximately) the user is, you're
probably better off using an IP->GeoLocation library/service like
Maxmind or HostIP.
You could also inspect the HTTP "Accept-Language" header in a server
side script.
The language setting for a browser has no bearing on geographical
location.
Yes, I know I can. I can do lots of things server side. What I want to know
is how to do it client side.
To what level of accuracy? You can determine the timezone, which gets
you within maybe 10 degrees of longitude *if* the user has set it
correctly for the location they are in, but that's it. The language
might give you a clue in regard to latitude, but I doubt it is
reliable at all.
How do you reconcile GMT+8 and en-US?
--
Rob
.
- References:
- Re: Locale in JavaScript?
- From: jhurstus@xxxxxxxxx
- Re: Locale in JavaScript?
- From: Simon Brooke
- Re: Locale in JavaScript?
- Prev by Date: Re: how to use "attachEvent"?;
- Next by Date: Re: five fun JavaScript questions
- Previous by thread: Re: Locale in JavaScript?
- Next by thread: Re: Locale in JavaScript?
- Index(es):
Relevant Pages
|