Stephen <ss*****@austin.rr.com> wrote in
news:mR*******************@twister.austin.rr.com:
Janwillem Borleffs wrote:
"Edo van der Zouwen" <ezouwen@haalweg_removthis_andthis_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.systemLanguage
navigator.userLanguage
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.language
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 .browserlanguage or
..systemlanguage 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="JavaScript1.2"><!--
// The following only works in JavaScript 1.2 or greater:
function showpage(code) {
location = ("index_" + code + ".html");
}
if (navigator.appName == 'Netscape')
var language = navigator.language;
else
var language = navigator.browserLanguage;
var code = language.substring(0,2);
if (code == 'pl' || code == 'nl' || code == 'en')
showpage(code);
else
showpage('en');
//--></SCRIPT>