Tinymce获得内容 [英] Tinymce get content
本文介绍了Tinymce获得内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试获取tinymce的内容,如下所示:
I try to get the content of tinymce, like this:
var hallo = tinyMCE.activeEditor.getContent();
alert(hallo);
但每次收到此消息时:
Uncaught TypeError: Cannot read property 'getContent' of null
我正在使用tinymce 4.
I am using tinymce 4.
谢谢
推荐答案
无法读取属性'getContent'为null
通常意味着 TinyMCE
无法找到您的文本框,这意味着有错误对textarea的类的引用
。
Cannot read property 'getContent' of null
often means that TinyMCE
is unable to find your textbox which means there is something wrong in the reference to textarea's class
.
<form method="post" action="somepage">
<textarea id="myTextArea" class="mceEditor">I should buy a boat. </textarea>
</form>
<button onclick="content()">Get content</button>
记下 mceEditor
类我们将现在通知 TinyMCE
编辑器:
Take note of mceEditor
class which we will now inform the TinyMCE
editor about :
<script type="text/javascript">
tinyMCE.init({
mode : "specific_textareas",
editor_selector : "mceEditor" //<<<----
});
</script>
现在只需点击按钮即可获得该文本框的内容。
And now simply get the contents of that textbox on the button click.
function content() {
alert(tinyMCE.get('myTextArea').getContent());
}
这是工作 DEMO
Here is working DEMO
这篇关于Tinymce获得内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文