将Javascript注入TinyMCE/YUI生成的iFrame中?

Sah*_*eva 5 javascript tinymce

我正在尝试将javascript(例如prototype/jquery)插入/加载到TinyMCE(tinymce.moxiecode.com)或YUI的文本编辑器( http://developer.yahoo.com/yui/editor/ )生成的iFrame中,以便更好地操作其中的对象/图像/DIV。

TinyMCE 生成的 iFrame 基本上是一个文本编辑器。我希望能够包含我可以操作的 div、添加侦听器等,以便“富文本编辑器”变得更丰富,而不仅仅是一个文本区域。

Tha*_*ama 0

您可以尝试以下操作。获取编辑器实例并根据需要设置内容。

// editor_id = the id of your former textarea
editor_instance = tinymce.EditorManager.getInstanceById('editor_id');
// replaces the editory content
editor_instance.setContent('<div>your_content</div>');

// or use the following, adds content
editor_instance.execCommand('mceInsertContent', false , '<div>your_content</div>');
Run Code Online (Sandbox Code Playgroud)