浏览器语言判断js方法

扫一扫,更幸福

演示地址

浏览器语言判断方法<script>// <![CDATA[
// function getLanguage() { if (navigator.appName == 'Netscape') var language = navigator.language; else var language = navigator.browserLanguage; if (language.indexOf('en') > -1) document.write('english');
else if (language.indexOf('nl') > -1) document.write('dutch');
else if (language.indexOf('fr') > -1) document.write('french');
else if (language.indexOf('de') > -1) document.write('german');
else if (language.indexOf('ja') > -1) document.write('japanese');
else if (language.indexOf('it') > -1) document.write('italian');
else if (language.indexOf('pt') > -1) document.write('portuguese');
else if (language.indexOf('es') > -1) document.write('Spanish');
else if (language.indexOf('sv') > -1) document.write('swedish');
else if (language.indexOf('zh') > -1) document.write('chinese');
else
document.location.href = 'english';
}
// End
// ]]></script>

 

 

如果您觉得本文对您有所帮助,可以请小哥哥喝杯茶(*^▽^*)

二维码

发表评论