Reputation: 3
I want to insert Javascript before </head>
per article/page in Joomla 3.x
I have had a little success using the direct php plugin for joomla using this code in an article:
<?php
JHtml::script(Juri::base() . 'files/js/jquery.this-min.js');
?>
However it inserts the script tag at the start of the script tags. I want to insert it just before the </head>
So that it comes after jquery.
For a temporary solution I have included it site wide and this allowed it to be placed just before </head>
and now the script works properly.
Has anyone had success in doing this?
Upvotes: 0
Views: 1383
Reputation: 2149
$doc = JFactory::getDocument();
$doc->addScript(JURI::base().'files/js/jquery.this-min.js');
That should do it. If you are using Joomla 3 you could consider using the jQuery provided by them, using JHtml::_('jquery.framework');
.
See: http://docs.joomla.org/J3.2:Javascript_Frameworks for more info on that.
Upvotes: 1