views:

107

answers:

1

I'm trying to insert/load javascript (e.g. prototype/jquery) into the iFrame generated by TinyMCE (tinymce.moxiecode.com) or YUI's text editor (http://developer.yahoo.com/yui/editor/) so as to better manipulate the objects/images/DIVs inside it.

The iFrame generated by TinyMCE is basically a text editor. I want to be able to include divs that I can manipulate, add listeners to, etc, so that the "rich text editor" becomes richer, and not just a textarea.

A: 

You may try the following. Get the editor instance and set the content as you wish.

// 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>');
Thariama