使用ckeditor原始碼編輯時,預設會將某些html tag以及tag的屬性取消掉

可是某些情況還是會需要使用,因此可以用以下的方式打開

 

方案1:

在ckeditor 的 config.js 加上這行

CKEDITOR.editorConfig = function( config ) {
config.allowedContent=true;
};



或是在需要使用的那一頁加上


如果覺得全部開放不妥,也可以只開放部分

方案2:

在ckeditor 的 config.js 加上這行

CKEDITOR.editorConfig = function( config ) {
config.allowedContent=false;  
//允許增加b這個class 
config.extraAllowedContent = 'b';
}
;

又或者,需要開放兩個以上的html tag,則可使用半形空白分隔,範例如下

config.extraAllowedContent = 'b iframe'

 

而不希望class(尤其是div要用到的)或是id被隱藏,可以參考這個

//允許使用者輸入特定的標籤、class或id
extraAllowedContent: 'iframe(*)[*] section(*); nav(*)[*]; div(*)[*];',

其中(*)代表開放class,[*]代表開放id,有用到()或[]則必須用分號;分隔,不能只使用半形空白

 

還想要更多資料可以看ckeditor官方文件

參考資料:

http://docs.ckeditor.com/#!/guide/dev_allowed_content_rules-section-string-format

http://docs.ckeditor.com/#!/guide/dev_advanced_content_filte

 

arrow
arrow
    全站熱搜

    not0000 發表在 痞客邦 留言(0) 人氣()