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

2014-03-22 45

<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 BS,dialog控件自适应大小
Jul 06 46
jQuery 选择表格(table)里的行和列及改变简单样式
Dec 15 45
js showModalDialog 弹出对话框的简单实例(子窗体)
Jan 07 37
JavaScript转换与解析JSON方法实例详解
Nov 24 41
深入浅析react native es6语法
Dec 09 45
实例讲解JavaScript中的this指向错误解决方法
Jun 13 48
React-Native中禁用Navigator手势返回的示例代码
Sep 09 60
手机访问当前页面