最新消息: 新版网站上线了!!!

yii加载css js方法

$cs=Yii::app()->clientScript;

//加载CSS文件
$cs->registerCssFile($cssFile);

//加载JS文件
$cs->registerScriptFile($jsFile);

//直接插入JS的方法:
$cs->registerScript(

'my-hello-world-1',
'var greetings = "Hello" + " " + "World";
alert(greetings);',
CClientScript::POS_END
);
//CClientScript::POS_HEAD : the script is inserted in the head section right before the title element.
//CClientScript::POS_BEGIN : the script is inserted at the beginning of the body section.
//CClientScript::POS_END : the script is inserted at the end of the body section.
//CClientScript::POS_LOAD : the script is inserted in the window.onload() function.
//CClientScript::POS_READY : the script is inserted in the jQuery's ready function.

转载请注明:谷谷点程序 » yii加载css js方法