浏览器语种检测,适合于多语言版本的站点
2008-04-30 08:23
381 查看
假如您的网站面向世界各地的冲浪者或对外开展商贸活动,检测来访者的浏览器语言类型就很现实了。这里提供
的脚本能够检测流露;浏览器的语言类型,一般中文能够识别为“zh”,英文版本的能够识别为“en”,然后根据判断的浏
览器语言类型导向不同语言版本的页面。当然您能够通过服务器端去解决这个问题,在客户端用这个脚本就能够了。
您需要将代码放在html的<head>区。然后做不同语言版本的页面即可。
<script language="javascript1.2">
<!--//
if (navigator.appname == netscape)
var language = navigator.language;
else
var language = navigator.browserlanguage;
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;
// end -->
</script>
的脚本能够检测流露;浏览器的语言类型,一般中文能够识别为“zh”,英文版本的能够识别为“en”,然后根据判断的浏
览器语言类型导向不同语言版本的页面。当然您能够通过服务器端去解决这个问题,在客户端用这个脚本就能够了。
您需要将代码放在html的<head>区。然后做不同语言版本的页面即可。
<script language="javascript1.2">
<!--//
if (navigator.appname == netscape)
var language = navigator.language;
else
var language = navigator.browserlanguage;
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;
// end -->
</script>
相关文章推荐
- JavaScript 检测浏览器语种,适合于多语言版本的站点
- 浏览器语种检测,适合于多语言版本的站点
- 浏览器检测脚本(各语言)
- 浏览器版本检测
- jquery检测浏览器版本等信息代码
- javascript 检测浏览器类型和版本的代码
- 检测浏览器及版本和信息
- 检测浏览器版本
- php检测浏览器语言
- userAgent,JS用户代理检测——判断浏览器内核、浏览器、浏览器平台、windows操作系统版本、移动设备、游戏系统
- ionic 检测版本更新,Android版,IOS在浏览器打开下载页面。
- WebGL 支持情况检测与已支持浏览器版本汇总
- 检测IE系列浏览器的各个版本
- JS-检测浏览器类型及版本
- IE6,IE7,IE8 CSS hacks 演示之 检测当前浏览器版本
- js 检测浏览器版本
- PPK提供的浏览器类型及版本检测方法
- jQuery 如何检测浏览器及版本
- jquery1.9 下检测浏览器类型和版本的方法