Spiga

How to Add JavaScript to Joomla Content

by Gabi Solomon

Sometimes you need to add some javascript to your joomla content, being either some type of ad ( google adsense or yahoo ) or maybe just a code to display a widget from another site.
I bet you have tried to add it to the content, but as you will see the editor will replace the code with the HTML coresponding code. Ex: < will become >.
This will make all the javascript code display on the page and nothing will happen.

The solution is quite simple, or at least the one i found :)
Login in as admin
Go to Site
Global Configuration
Default WYSIWYG Editor
Change it to No WYSIWYG Editor
Click Save.

Now go to Content:
Just add your Javascript in the Content Area
Click Save

Pretty basic solution. Sorry you need to do this each time you want to add javascript to you’re articles. havent found any other method. If you do please tell me in a comment to this article.

Cheers

Related Posts

  • Jgardiner
    When you say enter the JS in the content area, are you meaning create a new article that is the js and then point to the article? A bit confused here.
  • Godsendn
    brilliant !! thanks a million times
  • Thank you this nice post.
  • Thanks for the solution. It worked on my end
  • Great solution! Thank you very much xoxoxoxoxo
  • Shaveen Kaushal
    Thanks Sir, It help me a lot. Now problem solved.
  • The solution is rather simple, thanks! it works finally.
  • mugarurac
    Very useful, thanks a bunch
  • Very useful. I was struggling to add a widget onto my website and it wasnt happening. This is a very simple solution and it worked like a charm. Thank you very much.
  • stevoo
    When i try to save the content no matter how i enter it the javascript dissapears.

    How can i enter it so it will stick there !

    My content goes like this :

    <script type="text/javascript">
    <!--
    var state = 'hidden';
    function(dosometthing); // not the actuall one
    //-->
    </script>
    then i have an image and a map on it to link to variouis locations.

    But every time i save the Javascript vanishes .... and hints ?
  • then the only thing you could do is ask your super admin to do it
  • Pauloandes
    Sorry I didn't say... I've not Admin SuperAdmin Account, With my account I can only Manage content but I didn't see the option you told on that menu...
    Menu SITE
    Option: Global Config
  • sorry but i dont see the problem ... did you try the steps above ?
  • Pauloandes
    How do I know I haven't removed my site's Ins Dir?
    I'm trying to put de msn messenger script into a component and there's inly one it works.
    I make it behind the Main Menu and the Link works.
    But I need to put it inside content, or main page...
    Thx
  • Willem
    Obviously you did not remove the installation directory upon completion of the Joomla installation. Very dangerous indeed!!
  • that must be a bug with joomla since that is a setting in joomla ... and not a hack or something. changing a setting should not crash the site.
  • I didi what you told me. Choose no editor at Global configuration. When I click save. Bang! By front site and back site are gone. Where the hell are they?
    There come up a message like these:

    Not Found

    The requested URL /site3/installation/index.php was not found on this server.

    Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request
  • illank
    using jumi plugin from joomla.org can solve the problem, just try it
  • Good simple solution, should prove to be very useful. Does anybody know of a way to insert javascript into Joomla's frontend? I have tried using no wysiwyg editor in the frontend but i keep getting 403 errors when saving.
blog comments powered by Disqus