2

I was wondering if there is any direct hook to inject some javascript into tinymce iframe?

  • does tinymce have an iframe? can you elaborate? – Sisir Aug 2 '12 at 9:42
  • Yes it has. Whole editor area is an iframe. – jayarjo Aug 2 '12 at 12:59
  • Close-voted as off-topic. This question is javascript/TinyMCE related, not WordPress specific. – Chip Bennett Aug 2 '12 at 14:11
2

WordPress injects its own external script files in the TinyMCE editor iframe, see for example the wp-includes/js/tinymce/plugins/wpembed/plugin.js file:

(function ( tinymce ) {
    'use strict';

    tinymce.PluginManager.add( 'wpembed', function ( editor, url ) {
        editor.on( 'init', function () {
            var scriptId = editor.dom.uniqueId();

            var scriptElm = editor.dom.create( 'script', {
                id: scriptId,
                type: 'text/javascript',
                src: url + '/../../../wp-embed.js'
            } );

            editor.getDoc().getElementsByTagName( 'head' )[ 0 ].appendChild( scriptElm );
        } );
    } );
})( window.tinymce );

The plugin.js file is loaded in TinyMCE using the tiny_mce_plugins filter.

0

Not possible, Tinymce uses this javascript to create iframe, so you've to edit the javascript to load additional javascript file into iframe.

Thats why there will not be any hook to inject javascript into iframe.

  • This answer doesn't provide a solution. – David Riccitelli Apr 17 '17 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.