通过识别浏览器语言, 自动判断选择网站语言
根据识别用户的浏览器语言, 自动判断并跳转到相应的语言网页, 让你的网站更加国际化.
以下需要将代码放在HTML的
PHP/HTML:
- <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>
Tags: 网站.
如果你喜欢本文或对本站感兴趣, 请订阅本站 Feed [如何订阅Amazing]
转载原创文章请注明, 转载自: Amazing [http://punker.info]
本文链接: http://punker.info/network/internationalization-your-website-language.html
收藏到 | 引用地址 | 评论 RSS | 评论回复 [0]





