score:2

Accepted answer

To embed Javascript files into a Joomla module, you need to use the following code:

$document =& JFactory::getDocument();
$document->addScript(JURI::root() . "modules/mod_your_module/file.js");
$document->addScript(JURI::root() . "modules/mod_your_module/file2.js");
...

If you need to write custom Javascript, then you will need to write it like so:

$js = 'alert("alert message");';
$document->addScriptDeclaration($js);

Hope this helps.


Related Query

More Query from same tag