Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Getting Browser language and redirecting to appropriate site

Status
Not open for further replies.

Minarai

Technical User
Aug 5, 2001
12
US
I'm designing a multi-lingual site (At this point English and Japanese) and I want to create a script to direct the visitor to the appropriate gateway and set the default as english.

If I test the following code on my browser (IE 5.0), I get directed to the default English site even though my os and browser language is set to Japanese.

but if I remove the default it properly goes to the Japanese.

What should I do to correct this?
What am I doing wrong?

Thanks in advance..

<script language=&quot;javascript&quot;>
<!--
function getlanguage(){
language=navigator.language;
if(language){language=language.substring(0,2);}
else{language=&quot;z&quot;;}
switch (language){
case &quot;ja&quot; :
window.location=&quot;jap.htm&quot;;
break;
case &quot;en&quot; :
window.location=&quot;eng.htm&quot;;
break;
default :
window.location=&quot;eng.htm&quot;;
}

}
// -->
</script>
 
The language attribute of the navigator object is not supported by IE at all - it is undefined.
You will have to use VBScript to find out. I don't know how to do this. ;-)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top