首页 > 解决方案 > 修改帖子时如何在CKEditor上添加nofollow属性

问题描述

我正在使用CKEditor 4.5.5版本。

我添加下一个代码来添加nofollow。

它工作正常并存储了我的数据库。但是,当我修改帖子时,CKEditorauto-removed ref="nofollow"属性。

如何在 CKEditor 上加载原点属性?

——写页。添加nofollow代码-

CKEDITOR.on('instanceReady', function () {
    CKEDITOR.on('dialogDefinition', function (ev) {
        var editor = ev.editor;
        editor.dataProcessor.htmlFilter.addRules({
            elements: {
                a: function (element) {
                    if (!element.attributes.rel)
                        element.attributes.rel = 'nofollow';
                }
            }
        });
    });
});

标签: htmlckeditor

解决方案


您需要修改文件ckeditor_config.js. 添加以下代码:

config.extraAllowedContent = 'a[rel]';

推荐阅读