diff --git a/framework/web/CClientScript.php b/framework/web/CClientScript.php index 7e1d7fe64..6bee84a12 100644 --- a/framework/web/CClientScript.php +++ b/framework/web/CClientScript.php @@ -371,8 +371,11 @@ class CClientScript extends CApplicationComponent if($html!=='') { - $count=0; - $output=preg_replace('/<\\/title\s*>/is','$1<###head###>',$output,1,$count); + $count=0; + $output=preg_replace('/<\\/head\s*>/is','<###head###>$1',$output,1,$count); + if(!$count) + $output=preg_replace('/<\\/title\s*>/is','$1<###head###>',$output,1,$count); + if($count) $output=str_replace('<###head###>',$html,$output); else