【问题标题】:CKEDITOR, is return some strange charactersCKEDITOR,是返回一些奇怪的字符
【发布时间】:2010-06-06 01:09:03
【问题描述】:

有了CKEDITOR,当我使用JS获取文本编辑器的内容时​​,我又回来了:

<p>\u000a\u0009&nbsp;ad adad ad asd</p>\u000a

什么时候我应该得到:

<p>ad adad ad asd</p>

知道这里发生了什么吗?

唯一可能的原因是我在加载时动态创建了文本区域,并使用一个类来查找编辑器:

$('.guideItem-textarea').each(function(index, value){
    // ID of the textarea
    var targeteditor = $(this).attr('id');
    var targeteditorID = $(this).attr('id').replace('noteguide','');

    // Contents in the editor
    textareacontents = CKEDITOR.instances[targeteditor].getData();
});

有什么想法吗?

【问题讨论】:

    标签: ckeditor


    【解决方案1】:

    那些奇怪的字符是 unicode 控制字符。第一个是换行符,第二个是制表符。您示例中的数据真的是您问题中的值吗?也许您从其他来源预先填充了文本?

    在你弄清楚这一点后建议阅读: http://www.joelonsoftware.com/articles/Unicode.html

    【讨论】:

    • 布莱恩感谢您的回答。数据来自CKEDITOR:textareacontents = CKEDITOR.instances.noteguide1.getData();有没有办法解决这个问题?去掉所有 Unicode 控制字符?
    • 它似乎也只发生在 FIrefox,而不是 safari
    • 我会调查数据(即您问题中的“ad adad ad asd”)被放入 ckeditor 本身的位置:如果您使用 jquery 做某事,您可能会遇到一些特定于浏览器的问题文档中 text() 描述的行为:api.jquery.com/text 由于您有 jQuery,您可能会发现某种正则表达式可以执行以删除控制字符。比如:stackoverflow.com/questions/846797/…
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2012-10-06
    • 2020-04-20
    • 2019-07-05
    • 2017-07-04
    • 2018-03-11
    相关资源
    最近更新 更多