浏览器中的语言顺序为
de
zh-cn
if (navigator.appName == 'Netscape '){
var language = navigator.language;
}else{
//var language = navigator.browserLanguage;
var language=navigator.userLanguage;
}
alert(language);
/*
if (language.indexOf( 'en ') > -1) document.location.href = 'english.php ';
else if (language.indexOf( 'de ') > -1) document.location.href = 'german.php ';
else if (language.indexOf( 'zh ') > -1) document.location.href = 'chinese.php ';
else document.location.href = 'english.php ';
*/
------解决方案--------------------
navigator.userLanguage
这是我查到的说明:
Retrieves the operating system 's natural language setting.
就是说获取的应该是操作系统的设置语言.