Kindeditor在線文本編輯器如何過濾HTML
KindEditor是一套開源的HTML可視化編輯器,主要用于讓用戶在網(wǎng)站上獲得所見即所得編輯效果,兼容IE、Firefox、Chrome、Safari、Opera等主流瀏覽器。 KindEditor使用JavaScript編寫,可以無縫的與Java、.NET、PHP、ASP等程序接合。這個是官網(wǎng)上的介紹。
主頁:http://www.kindsoft.net/index.php
下載:http://www.kindsoft.net/down.php
示例:http://www.kindsoft.net/demo.php
在使用kindeditor文本編輯器時遇到的問題,客戶直接從Excel里粘貼文本內(nèi)容到文本編輯器中(能不能再懶一些),然后不調(diào)整粘貼內(nèi)容直接就保存(你敢不敢再懶一些)!對于這種很無語的行徑,我只能對他大吼一聲,我做一個標簽過濾吧,這樣你粘貼就不會出現(xiàn)問題了(慫?誰惹得起客戶)。
過濾方法也簡單:
KindEditor.ready(function (K) { editor = K.create('textarea[name="content"]', { filterMode: true,//是否開啟過濾模式 }); });
默認filterMode是關閉狀態(tài),首先把filterMode設置為true,然后增加htmlTags,指定要保留的HTML標記和屬性。哈希數(shù)組的key為HTML標簽名,value為HTML屬性數(shù)組,"."開始的屬性表示style屬性。數(shù)據(jù)類型:Object
KindEditor.ready(function (K) { editor = K.create('textarea[name="content"]', { filterMode: true,//是否開啟過濾模式 htmlTags : { font : ['id', 'class', 'color', 'size', 'face', '.background-color'], div : [ 'id', 'class', 'align', '.border', '.margin', '.padding', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.font-weight', '.background', '.font-style', '.text-decoration', '.vertical-align', '.margin-left' ], a : ['id', 'class', 'href', 'target', 'name'], embed : ['id', 'class', 'src', 'width', 'height', 'type', 'loop', 'autostart', 'quality', '.width', '.height', 'align', 'allowscriptaccess'], img : ['id', 'class', 'src', 'width', 'height', 'border', 'alt', 'title', 'align', '.width', '.height', '.border'], 'p,ol,ul,li,blockquote,h1,h2,h3,h4,h5,h6' : [ 'id', 'class', 'align', '.text-align', '.color', '.background-color', '.font-size', '.font-family', '.background', '.font-weight', '.font-style', '.text-decoration', '.vertical-align', '.text-indent', '.margin-left' ], pre : ['id', 'class'], hr : ['id', 'class', '.page-break-after'], 'br,tbody,tr,strong,b,sub,sup,em,i,u,strike,s,del' : ['id', 'class'], iframe : ['id', 'class', 'src', 'frameborder', 'width', 'height', '.width', '.height'] } }); });
以上所述是小編給大家介紹的Kindeditor在線文本編輯器如何過濾HTML,希望對大家有所幫助!
相關文章
JavaScript DOM節(jié)點操作方法總結(jié)
下面小編就為大家?guī)硪黄狫avaScript DOM節(jié)點操作方法總結(jié)。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2016-08-08完美解決spring websocket自動斷開連接再創(chuàng)建引發(fā)的問題
下面小編就為大家?guī)硪黄昝澜鉀Qspring websocket自動斷開連接再創(chuàng)建引發(fā)的問題。小編覺得挺不錯的,現(xiàn)在就分享給大家,也給大家做個參考。一起跟隨小編過來看看吧2017-03-03JS實現(xiàn)讀取Excel文件內(nèi)容并生成二維碼
這篇文章主要為大家介紹了如何使用JavaScript實現(xiàn)讀取Excel文件內(nèi)容并生成二維碼下載到本地,文中的示例代碼講解詳細,感興趣的小伙伴可以了解一下2022-04-04