Why does Joomla remove HTML tags <iframe>
and <script>
and how to insert them correctly?
Why does Joomla remove tags?
The thing is that by default the tags <iframe>
and <script>
are in the list of forbidden HTML tags for use in the Joomla visual editor. This behavior affects the default editor TinyMCE as well as the advanced editor JCE. You can choose an editor here:
System →Global Configuration → Site tab → Default Editor
You can also use the Switch Editor module.
- in the Joomla editor you are using,
- in the global Joomla configuration (for users of all groups except superuser).
How to allow tags in TinyMCE?
To allow <iframe>
and <script>
tags in the TinyMCE editor:
- Go to the list of Joomla plugins: Control Panel → Plugins, or System → Plugins.
- Find the Editor - TinyMCE plugin and go to its settings.
- In the required set (TinyMCE editor sets for different user groups), we find the option Prohibited elements.
- Remove iframe, script or all at once from the list.
- Add the required tag or tags for the Extended Valid Elements option.
- For Joomla 5: find the option Sandbox Iframes and disable it (this option may prevent the display of the iframe content).
- Save.
After this, the <iframe>
tag should no longer disappear from the TinyMCE visual editor for all users in the group corresponding to the editor suite, but for user groups that are intended for a different suite, the HTML <iframe>
tag will still be disallowed.
How to allow tags in JCE?
The previous instructions do not apply to the JCE visual editor and require separate steps.
How to insert <iframe> tag?
- Go to the list of editor profiles.
- Select the profile of the user group for which you want to allow tag insertion.
- Go to the Editor Parameters tab → Advanced tab.
- Option Extended Elements → enter iframe.
- Plugin Parameters tab → Media Support tab → Allow IFrames → select the appropriate value.
- Below in the same tab there is a setting Sandbox Iframes → we can disable it, or configure an exception through the following setting Sandbox URL Exclusions.
- Save.
How to insert <script> tag?
- Go to the list of editor profiles.
- Select the profile of the user group for which you want to allow tag insertion.
- Go to the Editor Parameters tab → Advanced tab.
- Option Extended Elements → enter script.
- Option Allow Javascript → select Yes.
- Plugin Parameters tab → Clipboard tab → Keep tags option → enter script.
- Save.
How to remove the ban in the global configuration of Joomla?
By default, all user groups except superuser have text filters that can be edited in General Settings. For example, if you want to allow users of the Manager group to insert <iframe>
tags via the visual editor in the frontend of a Joomla site, then:
- go to Control Panel → General Settings,
- Text Filters tab,
- find the required user group Manager,
- adjust as needed (for example, you can replace Black list with No filtering).