具有 jQuery 输出的 CKEditor 被截断,可能是因为特殊字符
我有以下正确生成 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>
"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>
但是当我 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我终于找到了答案。 Javascript 有一个内置函数,称为“escape”。所以这有效:
这是使用ajax。
I finally found the answer. There is a Javascript built-in function called "escape". So this worked:
And this is with ajax.
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