现在的位置: 首页 > 综合 > 正文

浏览器不同语言切换不同页面

2018年06月07日 ⁄ 综合 ⁄ 共 897字 ⁄ 字号 评论关闭
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
<script>
/*
Browser Language Redirect script- By JavaScript Kit
For this and over 400+ free scripts, visit http://www.javascriptkit.com
This notice must stay intact
*/

//Enter ISO 639-2 letter Language codes to detect (see: http://www.w3.org/WAI/ER/IG/ert/iso639.htm):
var langcodes=new Array("en","zh", "default")

//Enter corresponding redirect URLs (last one is for default URL):
var langredirects=new Array("english.html", "chinese.html", "default.html")

var languageinfo=navigator.language? navigator.language : navigator.userLanguage
var gotodefault=1

function redirectpage(dest){
if (window.location.replace)
window.location.replace(dest)
else
window.location=dest
}

for (i=0;i<langcodes.length-1;i++){
if (languageinfo.substr(0,2)==langcodes[i]){
redirectpage(langredirects[i])
gotodefault=0
break
}
}

if (gotodefault)
redirectpage(langredirects[langcodes.length-1])
</script>
</body>
</html>

抱歉!评论已关闭.