Getting the value from a TinyMCE textarea Getting the value from a TinyMCE textarea javascript javascript

Getting the value from a TinyMCE textarea


TinyMce has an api for accessing content from the editor.

This code will grab the html from the active editor:

// Get the HTML contents of the currently active editortinyMCE.activeEditor.getContent();// Get the raw contents of the currently active editortinyMCE.activeEditor.getContent({format : 'raw'});// Get content of a specific editor:tinyMCE.get('content id').getContent()


Use below syntax, which will remove unwanted character from your input textarea....

(((tinyMCE.get('YourTextAreaId').getContent()).replace(/( )*/g, "")).replace(/(<p>)*/g, "")).replace(/<(\/)?p[^>]*>/g, "");


Try

window.parent.tinymce.get('contentID').getContent();

For some reason, the stock-standard tinymce.get() call didn't work for me, so I tried this and it works. :)