如何使用javascript从tinyMCE获取我的格式化内容?

时间:2012-09-18 10:21:18

标签: javascript jquery tinymce

我已经安装了TinyMCE,当我的表单以传统方式发布(进入某些php页面)时,这不是问题,因为我可以传递变量throug stripslashes()函数或类似的东西。

不幸的是,我的一个表单是通过jquery $ .ajax模块传递的 - 并且任何PHP操作都是不可能的。有没有办法通过javascript传递完整格式化的tinyMCE输出,因为现在它看不到我已经完成的任何格式化。

1 个答案:

答案 0 :(得分:3)

根据这个答案:https://stackoverflow.com/a/6541822/349012这是可能的:

// Get the HTML contents of the currently active editor
tinyMCE.activeEditor.getContent();

// Get the raw contents of the currently active editor
tinyMCE.activeEditor.getContent({format : 'raw'});

// Get content of a specific editor:
tinyMCE.get('content id').getContent()

另一个参考:https://stackoverflow.com/a/11112221/349012