首頁
解決IE6/Google Chrome無法搜尋中文問題 列印 填寫電子郵件
(0 位用戶參與評分, 當前平均得到 0 顆星星)
Joomla! / 開發技術 / Eddy Chang / 週二, 24 二月 2009 17:51
在IE6(Internet Explorer 6)中,當使用搜尋功能時(例如搜尋「中文字」,網址會變成如下,UTF-8的「中文字」轉成「銝剜?摮」,然後無法進行搜尋的功能。 在Firefox 3.0.5中是可以正常進行搜尋功能,Firefox會自動轉碼:
component/search/%E4%B8%AD%E6%96%87%E5%AD%97/?ordering=newest&searchphrase=all
在IE7中是可以正常進行搜尋功能,IE7不會自動轉碼,但還是正常:
component/search/中文字/?ordering=&searchphrase=all
Google Chrome的搜尋也會出錯
component/search/%E4%B8%AD%E6?%E5%AD??ordering=newest&searchphrase=all

解決之法如下

 

修改/libraries/joomla/environment/uri.php的第347行左右的toString函式在 之前加入

$query=str_replace("%2F", "/", urlencode($query)); 
$query=str_replace("%3D", "=", $query);
$query=str_replace("%26", "&", $query); 
目的是讓$query的字串如果出現中文時,會先作urlencode,這樣在IE6或Google Chrome中的中文搜尋都可以正常運作了。

評論:

新增回應


驗證碼
更新

Tags: joomla1.5 | 修改

關於我something about me

eddy

Eddy Chang

Joomla!台灣站長、資擘(股)軟體工程師

最新留言Latest Comment