how to use js codes in joomla articles?

Avatar
  • Answered
I followed the steps you described in order to let iframe be shown and it worked and then applied the same steps on the script tag but still i cannot see the js code result on my page. can you plz tell what else i should do?

thank you.
regards,
Avatar
JacobIMH
Hello caroleriva, and thank you for your question. When you click on the HTML source button in the TinyMCE editor in Joomla, are you still seeing your <script> tags there, or have they been stripped out? If you followed the steps in our how to add an iframe to a Joomla 2.5 article, you should have removed the word script from the Prohibited Elements section. You might also need to make sure your Super Users are set to have no filtering by going to Site > Global Configuration > Text Filters in the admin panel. If you're still having issues getting it working, it could be the JavaScript code itself and how it's coded. I would recommend trying to insert this test JavaScript and making sure it's not getting stripped out when you save the article:

<script type="text/javascript"> alert("Hello world!"); </script>

It looks like Joomla automatically updates it to this after being saved:

<script type="text/javascript">// <![CDATA alert("Hello world!"); // ]]></script>

However when viewing the page, the JavaScript code is run right away and I get the pop-up message in my browser. If it's still not working for you please let us know. - Jacob