php自動(dòng)跳轉(zhuǎn)中英文頁面
更新時(shí)間:2008年07月29日 13:03:40 作者:
當(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>
<?
$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>
您可能感興趣的文章:
- 基于jQuery實(shí)現(xiàn)中英文切換導(dǎo)航條效果
- asp.net實(shí)現(xiàn)中英文多域名檢測(cè)的方法
- C++統(tǒng)計(jì)中英文大小寫字母、數(shù)字、空格及其他字符個(gè)數(shù)的方法
- js判斷字符長度及中英文數(shù)字等
- java實(shí)現(xiàn)十六進(jìn)制字符unicode與中英文轉(zhuǎn)換示例
- js判斷字符長度以及中英文數(shù)字等
- js截取固定長度的中英文字符的簡單實(shí)例
- php 中英文語言轉(zhuǎn)換類
- php 中英文語言轉(zhuǎn)換類代碼
- jquery結(jié)合html實(shí)現(xiàn)中英文頁面切換
相關(guān)文章
PHP+jQuery實(shí)現(xiàn)滾屏無刷新動(dòng)態(tài)加載數(shù)據(jù)功能詳解
這篇文章主要介紹了PHP+jQuery實(shí)現(xiàn)滾屏無刷新動(dòng)態(tài)加載數(shù)據(jù)功能,涉及php動(dòng)態(tài)讀取數(shù)據(jù)庫及加載數(shù)據(jù)實(shí)現(xiàn)滾屏無刷新效果的具體操作技巧,需要的朋友可以參考下2017-05-05
PHP 開發(fā)環(huán)境配置(Zend Server安裝)
運(yùn)行安裝文件(ZendServer-CE-php-5.3.2-5.0.1-Windows_x86.exe)開始安裝,選項(xiàng)請(qǐng)參照我的選擇。2010-04-04
php中g(shù)etservbyport與getservbyname函數(shù)用法實(shí)例
這篇文章主要介紹了php中g(shù)etservbyport與getservbyname函數(shù)用法,以實(shí)例形式分析了getservbyport與getservbyname函數(shù)獲取server端的端口等信息的方法,需要的朋友可以參考下2014-11-11
php實(shí)現(xiàn)圖片以base64顯示的方法
這篇文章主要介紹了php實(shí)現(xiàn)圖片以base64顯示的方法,較為詳細(xì)的分析了base64編碼格式顯示圖片的相關(guān)實(shí)現(xiàn)技巧與注意事項(xiàng),需要的朋友可以參考下2016-10-10

