如何从TinyMCE编辑器中提取HTML内容 [英] How to extract HTML content from TinyMCE Editor
本文介绍了如何从TinyMCE编辑器中提取HTML内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是Javascript / TinyMCE的初学者,我尝试了解如何从编辑器中获取HTML内容,并使用简单的alert()函数显示它。
I'm a beginner on Javascript/TinyMCE and I try to understand how is it possible to get the HTML content from the editor, and show it with a simple alert() function.
我的HTML页面上有这个极简主义配置:
I've this minimalist config on my HTML page :
<div id="tiny">
<script type="text/javascript">
tinyMCE.init({
// General options
mode : "specific_textareas",
editor_selector : "mceEditor"
});
</script>
</div>
<form method="post" action="somepage">
<textarea id="myarea1" class="mceEditor">This will be an editor.</textarea>
</form>
在 TinyMCE网站,他们解释说我必须使用这个:
On the TinyMCE Website, They explained that i have to use this :
// Get the HTML contents of the currently active editor
console.debug(tinyMCE.activeEditor.getContent());
tinymce.activeEditor.getContent()
我不知道为什么它不起作用
I don't know why it doesn't work
有人有个主意吗?
推荐答案
我不知道为什么它不起作用
它无效,因为
console.debug(tinyMCE.activeEditor.getContent());
tinymce.activeEditor.getContent();
这些报表未被执行。
尝试按照 FIDDLE ....
tinyMCE.init({
// General options
mode : "specific_textareas",
editor_selector : "mceEditor"
});
获取内容的功能....
Function for getting content ....
function get_editor_content() {
// Get the HTML contents of the currently active editor
console.debug(tinyMCE.activeEditor.getContent());
//method1 getting the content of the active editor
alert(tinyMCE.activeEditor.getContent());
//method2 getting the content by id of a particular textarea
alert(tinyMCE.get('myarea1').getContent());
}
点击按钮获取编辑内容......
Get the content of editor on button click ...
<button onclick="get_editor_content()">Get content</button>
这篇关于如何从TinyMCE编辑器中提取HTML内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文