安全“打印”文本区域中的原始 html 代码与 CKeditor 一起使用?

发布于 2024-08-18 14:32:09 字数 124 浏览 2 评论 0原文

我需要替换哪个字符才能从文本区域中的数据库安全地“打印”原始 HTML 代码,以便我可以使用 CKeditor 对其进行编辑?

或者是否有另一种现有的首选方法将数据导入 CKeditor 文本区域? (例如 AJAX)

Which character do I need to replace to safely 'print' raw HTML code from a database in a textarea, so I can edit this with CKeditor?

Or is there another existing preferred method of getting data into a CKeditor textarea? (e.g. AJAX)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

风蛊 2024-08-25 14:32:09

CKEditor 将使用文本区域的初始内容,因此您需要做的就是像平常一样对其进行转义,例如:

<textarea id="editor1"><p>My <strong>bold</strong> text</p></textarea>

另请参阅 CKEDITOR.replace

如果要在加载 CKEditor 后设置文本区域的内容,请使用 setData API 函数:

CKEDITOR.instances.editor1.setData('<p>This is the editor data.</p>');

在这两种情况下,CKEditor 都会加载原始 HTML 并执行使其工作所需的任何预处理。

CKEditor will use the initial contents of the textarea, so all you need to do is escape it as you normally would, e.g.:

<textarea id="editor1"><p>My <strong>bold</strong> text</p></textarea>

See also CKEDITOR.replace.

If you want to set the contents of the textarea after CKEditor is loaded, use the setData API function:

CKEDITOR.instances.editor1.setData('<p>This is the editor data.</p>');

In both cases, CKEditor will load the raw HTML and do whatever preprocessing is necessary to make it work.

调妓 2024-08-25 14:32:09

此外,您现在可以只获取从 ajax 或 jquery 返回数据的变量并将其附加到 .setData(data)。

Additionally you can now just take the variable that is returning the data from ajax or jquery and append it to the .setData(data).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文