php自动跳转中英文页面

yipeiwu_com6年前PHP代码库
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>

相关文章

PHP中时间加减函数strtotime用法分析

本文实例讲述了PHP中时间加减函数strtotime用法。分享给大家供大家参考,具体如下: 时间加减 <?php //获取本地 提取年份+1 $date=date("Y...

php之字符串变相相减的代码

  很极端的例子,一种变相解决的问题的思路,记录下来,以备后用。   如何去掉文件默认名字的后缀?   $fileName&n...

php adodb连接带密码access数据库实例,测试成功

<?     include('./class/adodb/adodb.inc.php');    ...

php实现的DateDiff和DateAdd时间函数代码分享

扩展php中的时间函数DateDiff和DateAdd function DateDiff($part, $begin, $end) { $diff = strtotime($end...

Apache下禁止php文件被直接访问的解决方案

Apache下禁止php文件被直接访问的解决方案

  一开始,我想在重写规则里直接禁止php后缀的URL被访问。但后来发现重写规则是递归调用的,如果在重写规则里直接禁止php,那么重写到php文件的规则也会失效。RewriteEngin...