Stephen <ss*****@austin .rr.com> wrote in
news:mR******** ***********@twi ster.austin.rr. com:
Janwillem Borleffs wrote:
"Edo van der Zouwen" <ezouwen@haalwe g_removthis_and this_xs4all.nl>
schreef in bericht
news:Xn******** *************** ******@216.168. 3.44...
But would love to do it in Javascript..... .
Anybody?
IE extends the navigator object with two properties you could
reference:
navigator.syste mLanguage
navigator.userL anguage
Doesn't work in other browsers and I'm not shure whether this would
work on a mac or not...
Gecko based browsers look like they use
navigator.langu age
My reference says this goes back to NN4.
... this doesn't seem to give exactly what the ACCEPT_LANGUAGE header
would have, but it might be close enough ...
Regards,
Stephen
JW
Thanks for both replies. However. the .userlanguage .browserlanguag e or
..systemlanguag e properties give the language of the browser or system.
In a browser, you can however also set the 'preferred language' in which
you can see a webpage.
For example, many people outside the US or UK have an english browser,
but would like to see webpages in their home language. This can not be
solved by using the properties above.
Any more ideas?
Thanks,
Edo.
P.S. By the way, for those interested, this is the code for checking the
browser language:
(example for dutch, polish and english users, which will be directed to
index_en.html, index_pl.html or index_nl.html)
<SCRIPT LANGUAGE="JavaS cript1.2"><!--
// The following only works in JavaScript 1.2 or greater:
function showpage(code) {
location = ("index_" + code + ".html");
}
if (navigator.appN ame == 'Netscape')
var language = navigator.langu age;
else
var language = navigator.brows erLanguage;
var code = language.substr ing(0,2);
if (code == 'pl' || code == 'nl' || code == 'en')
showpage(code);
else
showpage('en');
//--></SCRIPT>