自动跳转中英文页面
自动跳转中英文页面
发布时间:2016-12-29 来源:查字典编辑
摘要:PHP网页根据来访这的浏览器语言不同自动跳转中英文页面演示:http://www.gabion.cn当来访者浏览器语言是中文就进入中文版面国...

PHP网页根据来访这的浏览器语言不同自动跳转中英文页面

演示:http://www.gabion.cn

当来访者浏览器语言是中文就进入中文版面

国外的用户默认浏览器不是中文的就跳转英文页面

PHP代码:

<?

$lan=substr($HTTP_ACCEPT_LANGUAGE,0,5);

if($lan=="zh-cn")

print("<metahttp-equiv='refresh'content='0;URL=gb/index.htm'>");

else

print("<metahttp-equiv='refresh'content='0;URL=eng/index.htm'>");

?>

HTML网页根据来访这的浏览器语言不同自动跳转多语言页面

在<head></head>之间加入如下代码。

<script>

vartype=navigator.appName

if(type=="Netscape")

varlang=navigator.language

else

varlang=navigator.userLanguage

//cutdowntofirst2charsofcountrycode

varlang=lang.substr(0,2)

//英语

if(lang=="en")

window.location.replace('url')

//简体中文

elseif(lang=="zh-cn")

window.location.replace('url')

//繁体中文

elseif(lang=="zh-tw")

window.location.replace('url')

//德语

elseif(lang=="de")

window.location.replace('url')

//除上面所列的语言

else

window.location.replace('url')

</script>

推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
相关阅读
网友关注
最新php教程学习
热门php教程学习
编程开发子分类