自動(dòng)跳轉(zhuǎn)中英文頁面
更新時(shí)間:2006年10月09日 00:00:00 作者:
PHP 網(wǎng)頁根據(jù)來訪這的瀏覽器語言不同自動(dòng)跳轉(zhuǎn)中英文頁面
演示:http://www.gabion.cn
當(dāng)來訪者瀏覽器語言是中文就進(jìn)入中文版面
國外的用戶默認(rèn)瀏覽器不是中文的就跳轉(zhuǎn)英文頁面
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網(wǎng)頁根據(jù)來訪這的瀏覽器語言不同自動(dòng)跳轉(zhuǎn)多語言頁面
在 <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>
相關(guān)文章
模擬OICQ的實(shí)現(xiàn)思路和核心程序(一)
模擬OICQ的實(shí)現(xiàn)思路和核心程序(一)...2006-10-10php strstr查找字符串中是否包含某些字符的查找函數(shù)
strstr()函數(shù)的作用是:返回一個(gè)字符串在另一個(gè)字符串中首次出現(xiàn)的位置到后者末尾的子字符串(大小寫敏感)。2010-06-06