poo*_*oja 44 javascript tinymce
我有一系列的内容,然后我们如何在javascript中获取Tinymce textarea的内容
小智 69
我用代码解决了它:
// 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()
Run Code Online (Sandbox Code Playgroud)
activeEditor是当前编辑器,但我使用tinyMCE.get('editor1').getContent()无法获取我的编辑器的值,希望它可以帮助你
我的主页是机器鸟
Tinymce API:http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.getContent
z.e*_*yyo 30
让我们说你的mce textarea实例是:
<textarea id="editor1" ....></textarea>
Run Code Online (Sandbox Code Playgroud)
然后你得到如下内容:
var content = tinyMCE.getContent('editor1');
Run Code Online (Sandbox Code Playgroud)
如果你的意思是你在一个页面上有多个mce编辑器实例,并且你想获得内容,那么尝试这种方法:
var inst, contents = new Object();
for (inst in tinyMCE.editors) {
if (tinyMCE.editors[inst].getContent)
contents[inst] = tinyMCE.editors[inst].getContent();
}
Run Code Online (Sandbox Code Playgroud)
上面的代码将每个编辑器内容添加到一个数组中
小智 18
我有同样的问题.我已经解决了使用此代码:
tinyMCE.get('editor1').getContent();
Run Code Online (Sandbox Code Playgroud)
来源:spocke是作者
小智 5
就我而言(v4.3.12),以上方法都不起作用,所以我做了一个解决方法:
网页代码:
<div id="wrapper">
<textarea id="editable_container" name="editable_container"></textarea>
</div>
Run Code Online (Sandbox Code Playgroud)
jQuery 代码:
var iframe = $('#editable_container_ifr');
var editorContent = $('#tinymce[data-id="editable_container"]', iframe.contents()).html();
console.log(editorContent);
Run Code Online (Sandbox Code Playgroud)
我的tinyMCE编辑器的占位符文本区域在哪里editable_container
,可编辑区域的iframe id是通过_ifr
向占位符的id添加后缀生成的,并且content-editable
容器(包含格式化文本)有一个tinymce
带有data-id
占位符id属性的id。
归档时间: |
|
查看次数: |
68221 次 |
最近记录: |