一聚教程网:一个值得你收藏的教程网站

最新下载

热门教程

Ckeditor 自动过滤 html 实体以及不过滤 html 的方法

时间:2015-11-13 编辑:简简单单 来源:一聚教程网

解决Ckeditor编辑器不显示html实体,自动过滤html的问题

Ckeditor 4.5.4,在编辑的时候,使用源码编辑,当保存内容包含Javascript、Style标签的时候,数据库中有Javascript、Style标签,输入到页面也可以执行,但是我再次编辑的时候就不见了,是Ckeditor把它们过滤掉了,需要做如下配置:

    CKEDITOR.replace( 'textarea_id', { allowedContent: true });

最后又发现一个问题:

设置了{ allowedContent: true}后,虽然html没有被过滤,但是html实体被渲染成真正的html效果。

即,本来我想仅仅展示html代码,而不是让它渲染真正的html效果。

好在Ckeditor提供了JS操作Ckeditor实例,给编辑器赋值的接口setData('编辑器的默认值')。

原来的前端代码参考如下:

   
   

改造后的前端代码参考如下:

   


   
   

注意,服务端PHP获取编辑器的内容,参考代码如下:

    $_POST['']


ckeditor 在线编辑器 不过滤html,head,title

{Boolean}CKEDITOR.config.fullPageSince: 3.1 Indicates whether the contents to be edited are being input as a fullHTML page. A full page includes the ,, and elements.The final output will also reflect this setting, including the contents only if this setting is disabled.

config.fullPage = true;Default Value:false


修改目录下面的

config.js

CKFinder.customConfig = function( config )
{
    // Define changes to default configuration here. For example:
    // config.skin = 'v1';
     config.language = 'zh-cn';
     config.fullPage = true;//允许包含html标签
};

热门栏目