Joomla!

How to add inline JavaScript to your Joomla! components

Written by Ian Carnaghan · 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
Written by Ian Carnaghan
I am a software developer and online educator who likes to keep up with all the latest in technology. I also manage cloud infrastructure, continuous monitoring, DevOps processes, security, and continuous integration and deployment. In my spare time I teach undergraduate classes in web development. Profile

Leave a Reply

avatar
  Subscribe  
Notify of