#1
|
|||
|
|||
如何做到不同的浏览器语言访问不同的页面,使你的站点全球化……
经过一个多小时的改版,我的签名站点(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/ 遗憾的是没有阿拉伯语言!
__________________
.mobi站点典范: http://takeda.mobi http://isbank.mobi 喜欢.mobi的, 请访问: http://www.likemobi.com |
#2
|
|||
|
|||
總會用到的 mark一下^^
|
#3
|
|||
|
|||
__________________
.mobi站点典范: http://takeda.mobi http://isbank.mobi 喜欢.mobi的, 请访问: http://www.likemobi.com |
#4
|
|||
|
|||
直接通过IP判断可以吗???
|
#5
|
|||
|
|||
ip判斷要用ip數據庫 效果不一樣
|
#6
|
|||
|
|||
呵呵,这个不需要IP库,是根据用户的浏览器语言自动判断跳转到相应页面的,更加符合用户习惯!
__________________
.mobi站点典范: http://takeda.mobi http://isbank.mobi 喜欢.mobi的, 请访问: http://www.likemobi.com |
#7
|
||||
|
||||
我正需要这个效果, 取来即用, 爽!!!
问候dfmzhh, 您辛苦了!!! |
#8
|
|||
|
|||
__________________
.mobi站点典范: http://takeda.mobi http://isbank.mobi 喜欢.mobi的, 请访问: http://www.likemobi.com |
#10
|
|||
|
|||
IIIIII
IIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIII IIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIII IIIIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIIIII IIIIII IIII IIII IIIIII IIIIII IIII IIII IIIIIIIIIIIIIIIIIIIIIIIIII IIII IIII IIIIIIIIIIIIIIIIIIIIIIIIII IIII IIII IIIIII IIIIII IIIIIIIIIIIIIIIIIIIIIIIIII IIIIII IIIIII IIIIIIIIIIIIIIIIIIIIIIIIII IIIIII IIIIII IIII IIII IIII IIII IIII IIIIII IIII IIII IIII IIII IIIIII IIII IIII IIII IIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIII IIII IIII IIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIII IIII IIII IIII IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII IIII IIII IIIIII IIII IIII IIII IIIIIIIIIIII IIIIIIII IIIIIIIIII IIII II IIII IIIIIIIIIIIIIIIIIIIIIIIIII IIII IIII IIIIIIIIIIIIIIIIIIIIIIIIII IIII IIII IIIIII IIIIII IIIIIIIIIIIIIIIIIIIIIIIIII IIIIII IIIIII IIIIIIIIIIIIIIIIIIIIIIIIII IIIIII IIIIII IIII IIII IIIIII IIIIII IIII IIII IIIIII IIIIII IIII IIII IIIIII IIIIII IIII IIII IIIIII IIIIII IIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIIIIIIIIIIIIIIIIII IIIIIIIIIIIIIIIIIIIIIIIIII IIII IIII IIIIII IIIIII IIII IIII IIIIII IIIIII
__________________
域名列表 |