clientScript()->registerScriptFile() insert scripts after HTML tag


I couldn’t figure out what’s wrong in my case…

When I call


it can actually output the script file:


   <div id="footer"> </div>

   <div class="overlay"></div>


</html><script type="text/javascript" src="/assets/80e38ef9/jquery.js"></script> 

<script type="text/javascript" src="/assets/80e38ef9/jquery.yiiactiveform.js"></script>

As you see the script tag always render after the HTML tag… no luck with this :(

It should render right after the open <head> tag…

And one more question… what’s the different between using registerScriptFile() and CHtml::scriptFile()?

Please help me!! Thanks.



Yii::app()->clientScript->registerScriptFile('somescript.js', CClientScript::POS_HEAD);

Hi, thanks for the answer but I’ve tried this and it just kept appending after </html>…

really weird… I didn’t find any post that has the similar situation like this…

help please :-[

Any chance you have malformed html in your layout?

I’ve checked many times… the layout should be well-formed :-X

Still fighting with it…

Thank you.