具有 jQuery 输出的 CKEditor 被截断,可能是因为特殊字符

发布于 2024-11-02 10:05:54 字数 1209 浏览 5 评论 0原文

我有以下正确生成 CKEditor 的代码:

<script>
$(function(){
  $("#newWrite_body").ckeditor({
                                 extraPlugins : 'autogrow',
                                 autoGrow_maxHeight : 800});
});
</script>

然后我从网页中抓取一些文本,将其粘贴到编辑器中,并在提交时提醒文本返回,它显示:

<p>
    <b>Fort McKay, Alberta (CNN)</b> -- Celina Harpe was 7 when her grandfather 
       made a prediction that would forever change her life.</p>
<p>
    &quot;I won&#39;t see it, I&#39;m too old now, but it&#39;s going to be 
    really bad,&quot; she recalls him saying on a warm summer night after 
    returning from a moose hunt. The two were standing on a hill that overlooks 
    the birch-and-spruce-lined river here in far northwest Canada.</p>

但是当我 echo 它返回时从插入之前的 PHP 代码来看,它被简化为:

<p>
    <b>Fort McKay, Alberta (CNN)</b> -- Celina Harpe was 7 when her grandfather 
    made a prediction that would forever change her life.</p>
<p>

显然特殊字符被删除。我所有逃离他们和/或改变他们的尝试都是徒劳的。

将这些内容从 CKEditor 的文本转换为 PHP 中可 POST 的值的正确方法是什么?

I have the following code that correctly generates the CKEditor:

<script>
$(function(){
  $("#newWrite_body").ckeditor({
                                 extraPlugins : 'autogrow',
                                 autoGrow_maxHeight : 800});
});
</script>

Then I grab some text from a web page, paste it into the editor, and alert the text back upon submitting it shows:

<p>
    <b>Fort McKay, Alberta (CNN)</b> -- Celina Harpe was 7 when her grandfather 
       made a prediction that would forever change her life.</p>
<p>
    "I won't see it, I'm too old now, but it's going to be 
    really bad," she recalls him saying on a warm summer night after 
    returning from a moose hunt. The two were standing on a hill that overlooks 
    the birch-and-spruce-lined river here in far northwest Canada.</p>

But when I echo it back from the PHP code before the insert, it is reduced to:

<p>
    <b>Fort McKay, Alberta (CNN)</b> -- Celina Harpe was 7 when her grandfather 
    made a prediction that would forever change her life.</p>
<p>

Apparently the special characters are being dropped. All my attempts to escape them and/or convert them have been futile.

What is the proper way to convert these from CKEditor's text to a POST-able value in PHP?

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

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

发布评论

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

评论(2

爱的十字路口 2024-11-09 10:05:54

我终于找到了答案。 Javascript 有一个内置函数,称为“escape”。所以这有效:

var text = escape(str);
// THEN POST STRING VIA AJAX

这是使用ajax。

I finally found the answer. There is a Javascript built-in function called "escape". So this worked:

var text = escape(str);
// THEN POST STRING VIA AJAX

And this is with ajax.

舟遥客 2024-11-09 10:05:54

ckEditor 中有一个名为 CKEDITOR.config.htmlEncodeOutput 的配置设置,

这可能就是您想要的。

ckEditor 配置文档

There's a config setting inside ckEditor called CKEDITOR.config.htmlEncodeOutput

That may be what you want.

ckEditor Configuration Documentation

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