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:

SystemGlobal ConfigurationSite tab → Default Editor

You can also use the Switch Editor module.

Next, you need to remove the ban on using the required HTML tags: 
  1. in the Joomla editor you are using,
  2. 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:

  1. Go to the list of Joomla plugins: Control PanelPlugins, or SystemPlugins.
  2. Find the Editor - TinyMCE plugin and go to its settings.
  3. In the required set (TinyMCE editor sets for different user groups), we find the option Prohibited elements.
  4. Remove iframe, script or all at once from the list.
  5. Add the required tag or tags for the Extended Valid Elements option.
  6. For Joomla 5: find the option Sandbox Iframes and disable it (this option may prevent the display of the iframe content).
  7. 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?

  1. Go to the list of editor profiles.
  2. Select the profile of the user group for which you want to allow tag insertion.
  3. Go to the Editor Parameters tab → Advanced tab.
  4. Option Extended Elements → enter iframe.
  5. Plugin Parameters tab → Media Support tab → Allow IFrames → select the appropriate value.
  6. 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.
  7. Save.

How to insert <script> tag?

  1. Go to the list of editor profiles.
  2. Select the profile of the user group for which you want to allow tag insertion.
  3. Go to the Editor Parameters tab → Advanced tab.
  4. Option Extended Elements → enter script.
  5. Option  Allow Javascript → select Yes.
  6. Plugin Parameters tab → Clipboard tab → Keep tags option → enter script.
  7. 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:

  1. go to Control Panel → General Settings,
  2. Text Filters tab,
  3. find the required user group Manager,
  4. adjust as needed (for example, you can replace Black list with No filtering).