js 判断浏览器使用的语言示例代码

2014-03-22 26

<script type="text/javascript"> 
var language = navigator.browserLanguage?navigator.browserLanguage:navigator.language; 
alert(language); 
if (language.indexOf('en') > -1) document.location.href = 'english.htm'; 
else if (language.indexOf('nl') > -1) document.location.href = 'dutch.htm'; 
else if (language.indexOf('fr') > -1) document.location.href = 'french.htm'; 
else if (language.indexOf('de') > -1) document.location.href = 'german.htm'; 
else if (language.indexOf('ja') > -1) document.location.href = 'japanese.htm'; 
else if (language.indexOf('it') > -1) document.location.href = 'italian.htm'; 
else if (language.indexOf('pt') > -1) document.location.href = 'portuguese.htm'; 
else if (language.indexOf('es') > -1) document.location.href = 'Spanish.htm'; 
else if (language.indexOf('sv') > -1) document.location.href = 'swedish.htm'; 
else if (language.indexOf('zh') > -1) document.location.href = 'chinese.htm'; 
else 
document.location.href = 'english.htm'; 
</script>
展开阅读全文

更多Javascript文章

jQuery 中使用JSON的实现代码
Dec 01 26
js截取字符串的两种方法及区别详解
Nov 05 24
关于JS中prototype的理解
Sep 07 25
微信小程序实现跟随菜单效果和循环嵌套加载数据
Nov 21 26
js replace替换字符串同时替换多个方法
Nov 27 18
微信小程序实现菜单左右联动
May 19 29
浅谈Web Storage API的使用
Jun 23 46
手机访问当前页面