How to add inline JavaScript to your Joomla! components

H

How Can We Help?

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");
    });
');
?>

About the author

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.

About Author

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.

Follow Me