4

我正在使用 ckeditor 撰写电子邮件,我正在使用它生成的 html 来发送 html 电子邮件广告,我还需要文本版本,因此在电子邮件中同时包含 html 和纯文本版本将避免垃圾邮件。

从java中的ckeditor html代码获取文本的方法是什么。

4

1 回答 1

13

这是一个非常简单的 JavaScript 调用:

CKEDITOR.instances.yourEditorInstance.getData() 

回报:

<h1>Apollo 11</h1>    
<p><b>Apollo 11</b> was the spaceflight that landed the first humans, Americans <a href="http://en.wikipedia.org/wiki/Neil_Armstrong" title="Neil Armstrong">Neil Armstrong</a> and <a href="http://en.wikipedia.org/wiki/Buzz_Aldrin" title="Buzz Aldrin">Buzz Aldrin</a>, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.</p>

然而:

CKEDITOR.instances.yourEditorInstance.editable().getText() 

回报:

Apollo 11
Apollo 11 was the spaceflight that landed the first humans, Americans Neil Armstrong and Buzz Aldrin, on the Moon on July 20, 1969, at 20:18 UTC. Armstrong became the first to step onto the lunar surface 6 hours later on July 21 at 02:56 UTC.
于 2013-02-25T13:08:21.133 回答