Hello
I have a piece of JavaScript code here (which somebody on the Tek-Tips forum kindly helped me out with):
<SCRIPT language="javascript">
function getlanguage(){
language=navigator.language;
if(language) {language=language.substring(0,2);}
else {language="z";}
switch(language) {
case 'en' : window.location =
' case 'de' : window.location =
' default : window.location =
' }
}
</SCRIPT>
The site, I am concerned about has a Russian language home page, but I wish to redirect visitors who are viewing the site from an English language browser (Netscape or Explorer) to an English version of the Russian site.
The two pages above, that is,
and
are test pages, but represent the Russian home page and the English version respectively.
The problem is that the redirection doesn't work (at least, not for me: I have visited the Russian version through IE6).
Does anybody know why this script isn't working?
A Russian colleague of mine suggests that the script isn't working "because the function getlanguage() isn't called in
the Web page". He also suggests that the script should make use of a variable which can identify the browser's language.
Incidentally, what does the following do:
language=navigator.language;
Any help would be most appreciated.
Best wishes
LaPluma
I have a piece of JavaScript code here (which somebody on the Tek-Tips forum kindly helped me out with):
<SCRIPT language="javascript">
function getlanguage(){
language=navigator.language;
if(language) {language=language.substring(0,2);}
else {language="z";}
switch(language) {
case 'en' : window.location =
' case 'de' : window.location =
' default : window.location =
' }
}
</SCRIPT>
The site, I am concerned about has a Russian language home page, but I wish to redirect visitors who are viewing the site from an English language browser (Netscape or Explorer) to an English version of the Russian site.
The two pages above, that is,
and
are test pages, but represent the Russian home page and the English version respectively.
The problem is that the redirection doesn't work (at least, not for me: I have visited the Russian version through IE6).
Does anybody know why this script isn't working?
A Russian colleague of mine suggests that the script isn't working "because the function getlanguage() isn't called in
the Web page". He also suggests that the script should make use of a variable which can identify the browser's language.
Incidentally, what does the following do:
language=navigator.language;
Any help would be most appreciated.
Best wishes
LaPluma