经过一个多小时的改版,我的签名站点(TAKEDA)终于可以根据不同的浏览器访问不同的页面了,呵呵,好玩啊,只是时间有限,仅仅提供了日文页面和一个英文页面,经过我的测试,是非常成功的,也希望更多的朋友测试(不同语言的浏览器),现将代码与广大版友分享:
PHP/HTML:
你需要将代码放在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>
ASP:
你需要将代码放在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>
唯一注意的一点,不要让首页进入死循环就OK了噢!也就是页面不要跳转向自己……
另外,提供一个在线翻译的站点(可以处理英汉在线翻译、汉英在线翻译、日语、韩语、法语、德语、俄语、西班牙语、葡萄牙语、意大利语、荷兰语、希腊语等十三种语言的在线翻译。):
http://tran.httpcn.com/
遗憾的是没有阿拉伯语言!