How to add javascript to joomla module?

simekadam picture simekadam · Jun 1, 2011 · Viewed 19.4k times · Source

Hi I have problem with adding javascript into a joomla module..I've found some solution, but it's not working..

$document = &JFactory::getDocument();
$document->addScript("/career.js");    

These two lines I have in my module, but the script isn't in rendered site.. The file is in root of my web (for test purposes only).

Thanks for your help

Answer

Yesceeohhh picture Yesceeohhh · Jun 12, 2012

Try this, it's working perfectly.

$document = &JFactory::getDocument();
$document->addScript('modules'.DS.'MOD_YOURMODULENAME'.DS.'javascript.js');