New to Joomla

How to do anything with Joomla

Home Joomla blog Joomla tutorials Using javascript with Joomla
Using javascript with Joomla PDF Print E-mail
Written by Administrator   
Monday, 02 August 2010 14:24

Once you have a Joomla site running, sooner or later you may want to use javascript, and if you are a more advanced user that's likely to mean jQuery too.

This tutorial is about using javascript of jQuery with Joomla, showing exactly what you need and how to set it up so that it works.

Overview of using javascript with Joomla

Joomla stores the articles that will be published on your website in a database. When Joomla stores the pages it expects text and images, not javascript or html. If you try to put javascript directly onto the page like this . . .

using javascript in joomla

what you you will see on the web page is . . .

using javascript in joomla

So it's obvious that is not going to work. The javascript is being interpreted as plain text instead of being executed by the browser. What we need is a way to insert the javascript directly into the page.

One way to work around this is to use a plain text editor in Joomla, or to click the [show/hide] link above the editor icons, which toggles the visual editor off and shows the actual code . . .

adding javascript to joomla

this does work around the difficulty, and so the browser does execute the javascript, in this case showing an alert.

javascript in joomla

That's one way, but it's not very convenient.

 

 

Last Updated on Monday, 02 August 2010 15:33