Saturday, January 21, 2012

[Joomla] Load CSS and Javascript

Load CSS:
$document =& JFactory::getDocument();
$document->addStyleSheet('http://localhost/css/style.css');

Load Javascript:
$document =& JFactory::getDocument();
$document->addScript('http://localhost/js/script.js');

jQuery noConflict():
$document =& JFactory::getDocument();
$document->addScript('http://localhost/js/script.js');
$document->addScriptDeclaration('jQuery.noConflict()');

Note: In loading a script, the path should be a url, not a directory.

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...