Click to See Complete Forum and Search --> : browser's language detection


Jessica Nieves
April 9th, 2002, 06:01 PM
I have this code to detect a browsers language nad if it is not en-us or es-us it opens a popup window.
My problem is that it not workin, sometimes it reads the machine language.
Please someone help me soon.

if (navigator.appName == 'Netscape')
var language = navigator.language;
else
var language = navigator.userLanguage;
//I also tried
//var language = navigator.userLanguage;
//but it didnt work
alert("Current Language: " + language)
if (!((language.indexOf('en-US') > -1) || (language.indexOf('es-US') > -1) || (language.indexOf('en-us') > -1) || (language.indexOf('es-us') > -1)))
{
alert("Current Language (inside): " + language)
window.open("/path/language.html","","height=600,width=630,resizable=1,scrollbars=0,toolbar=0,location=0,directories=0,status=1,menubar=0")
}

JNP

websmith99
October 25th, 2002, 04:08 PM
It works for me when using IE6 and NN6.

When I use NN4 then I noticed it is reading some internal default of "en" (English) even when I go to the preferences and change the language to "en-US" (English/United States) or even "is" (Icelandic).