从TinyMCE文本区域获取价值 [英] Getting the value from a TinyMCE textarea

查看:72
本文介绍了从TinyMCE文本区域获取价值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个使用TinyMCE的网站新闻编辑器.我想做的是有一个按钮(在TinyMCE编辑器本身之外),我可以单击该按钮以扫描文本区域中的任何图像,然后将这些图像列出作为用于所述新闻文章的缩略图的选项.

I have a news editor for my site with which I am using TinyMCE. What I would like to be able to do is have a button (outside of the TinyMCE editor itself) that I can click to scan the textarea for any images, then list those images as options to use for a thumbnail image for said news article.

要了解我的意思,请在此处查看此链接: https://docs.google .com/leaf?id = 0B05m73kzudwPNzUwZjkyNmItYjZkMy00NTdlLTlklkctctrGRhYThjMzNjNTM5& hl = zh_CN

For an idea of what I mean, please see this link here: https://docs.google.com/leaf?id=0B05m73kzudwPNzUwZjkyNmItYjZkMy00NTdlLTlkNDctOGRhYThjMzNjNTM5&hl=en_US

我的问题是,当textarea中有文本时,document.getElementById('NewsArticle').value不返回任何内容

My problem is that document.getElementById('NewsArticle').value is not returning anything when there is text in the textarea

另一个潜在的问题是,在文本区域中显示的内容不是实际的代码,而是图像等,因此我不确定它是否一开始就可以使用,但是由于在提交表单时,数据[新闻] [article]价值又回到了文字中,我认为可能会有机会.

The other potential problem is that whats shown in the textarea is not actual code, but images etc too so I wasn't sure it would even work in the first place, but since when the form is submitted the data[News][article] value is back into text, I thought there might be a chance.

如果有人知道如何获取tinyMCE文本区域的内容或代码,或者有更好的解决方案,我很想听听

If anyone knows how to get either the content or code for the tinyMCE textarea, or has a better solution, I'd be interested to hear

推荐答案

TinyMce具有

TinyMce has an api for accessing content from the editor.

此代码将从活动编辑器中获取html:

This code will grab the html from the active editor:

// 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()

这篇关于从TinyMCE文本区域获取价值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆