How to add inline JavaScript to your Joomla! components

13 sec read

JavaScript code can directly be declared within a component or module’s display view

<?php
$document = &JFactory::getDocument();
$document->addScriptDeclaration('
 
 alert("An inline JavaScript Declaration");
 
');
?>

For more information visit: http://docs.joomla.org/Adding_JavaScript

<?php
$document = &JFactory::getDocument();
$document->addScriptDeclaration('
    window.event("domready", function() {
        alert("An inline JavaScript Declaration");
    });
');
?>

Last Updated On March 25, 2018

Leave a Reply

avatar
  Subscribe  
Notify of