教程集 www.jiaochengji.com
教程集 >  脚本编程  >  php  >  正文 自动跳转中英文页面

自动跳转中英文页面

发布时间:2016-10-27   编辑:jiaochengji.com
教程集为您提供自动跳转中英文页面等资源,欢迎您收藏本站,我们将为您提供最新的自动跳转中英文页面资源
PHP 网页根据来访这的浏览器语言不同自动跳转中英文页面 
演示:http://www.gabion.cn
当来访者浏览器语言是中文就进入中文版面
国外的用户默认浏览器不是中文的就跳转英文页面
PHP代码:
<?
        $lan = substr($HTTP_ACCEPT_LANGUAGE,0,5);
        if ($lan == "zh-cn")
           print("<meta http-equiv='refresh' content = '0;URL = gb/index.htm'>");
        else
           print("<meta http-equiv='refresh' content = '0;URL = eng/index.htm'>");
?>
HTML网页根据来访这的浏览器语言不同自动跳转多语言页面 
在 <head> </head> 之间加入如下代码。
<script> 
var type=navigator.appName 
if (type=="Netscape") 
var lang = navigator.language 
else 
var lang = navigator.userLanguage 
//cut down to first 2 chars of country code 
var lang = lang.substr(0,2) 
// 英语
if (lang == "en") 
window.location.replace('url') 
// 简体中文
else if (lang == "zh-cn") 
window.location.replace('url') 
// 繁体中文
else if (lang == "zh-tw") 
window.location.replace('url') 
// 德语
else if (lang == "de") 
window.location.replace('url') 
// 除上面所列的语言
else 
window.location.replace('url')
</script>

您可能感兴趣的文章:
自动跳转中英文页面
js 控制页面跳转的五种方法
js 3秒后跳转页面实例代码
js实现用户登录自动跳转的代码
php 301重定向跳转解决方法
php如何实现页面跳转
js 页面自动跳转在safari下无效的解决方法
ASP判断客户端浏览器语言自动跳转
js实现wap浏览自动跳转到wap页面
网页页面自动刷新三种方法

上一篇:随机头像PHP版 下一篇:ip签名探针
[关闭]
~ ~