婷婷综合国产,91蜜桃婷婷狠狠久久综合9色 ,九九九九九精品,国产综合av

主頁 > 知識庫 > 使用Js獲取、插入和更改FCKeditor編輯器里的內(nèi)容

使用Js獲取、插入和更改FCKeditor編輯器里的內(nèi)容

熱門標(biāo)簽:智能電銷機(jī)器人真的好嗎 長春銷售外呼系統(tǒng)業(yè)務(wù) 株洲外呼營銷系統(tǒng)有哪些 興化400電話辦理多少錢 四平電話機(jī)器人哪家好 企業(yè)電話機(jī)器人辦理 靈聲智能電話機(jī)器人招聘 天津電銷卡外呼系統(tǒng)線路 長春防封卡電銷卡套餐

之前在一個系統(tǒng)里使用了FCKeditor編輯器,由于項(xiàng)目需求需要在FCKeditor里添加一個自定義的按鈕用于實(shí)現(xiàn)自己的需求

主要是在點(diǎn)擊該按鈕時刪除或添加FCKeditor編輯器里的內(nèi)容

其實(shí)是一個很簡單的需求,本來以為在FCKeditor可以很容易的實(shí)現(xiàn)
在Google上搜索自定義按鈕,插件開發(fā),經(jīng)過近二個小時的摸索最終還是沒有實(shí)現(xiàn)不知是我太笨還是自定義插件太難啦

通過JS方式來處理

1.在頁面中添加checkbox元素并綁定事件,選中該元素時將在FCKeditor內(nèi)容里添加"{#book#}"字符串(該字符串會在適當(dāng)?shù)臅r候被替換成其他內(nèi)容),取消選中時則刪除

label>input type="checkbox" id="lineBook" onclick="chk_but();"/>添加/刪除復(fù)選框/label>

2.添加Js處理FCKeditor內(nèi)容(添加或刪除"{#book#}"字符串),'txtContent'為FCKeditor的ID控控件ID

script type = "text/javascript" >
//"添加/刪除復(fù)選框"點(diǎn)擊時如果按鈕選中則添加"{#book#}"字符串到FCK內(nèi)容里,反之刪除字符串
//lineBook為FCK的ID號
function chk_but() {
  if (window.FCKeditorAPI !== undefined  FCKeditorAPI.GetInstance('txtContent') !== undefined) {
    if (document.getElementById('lineBook').checked) {
      FCKeditorAPI.GetInstance('txtContent').EditorDocument.body.innerHTML += "{#book#}";
    } else {
      FCKeditorAPI.GetInstance('txtContent').EditorDocument.body.innerHTML = FCKeditorAPI.GetInstance('txtContent').EditorDocument.body.innerHTML.replace("{#book#}", "");
    }
  }
} //end function chk_lineBook()
//內(nèi)容里如果有{#book#}則選中"添加/刪除復(fù)選框"
if (document.getElementById('txtContent').value.indexOf('{#book#}') >= 0 
   window.FCKeditorAPI !== undefined 
   FCKeditorAPI.GetInstance('txtContent') !== undefined) {
  document.getElementById('lineBook').checked = true;
} 
/script>

參考:

官網(wǎng):http://ckeditor.com/

獲取或更改內(nèi)容值:http://bbs.csdn.net/topics/360086762

創(chuàng)建插件:http://docs.cksource.com/FCKeditor_2.x/Developers_Guide/Customization/Plug-ins

接著給大家分享一下JS操作Fckeditor的一些常用方法

//向編輯器插入指定代碼 
function insertHTMLToEditor(codeStr){ 
 var oEditor = FCKeditorAPI.GetInstance("content");
 oEditor.InsertHtml(codeStr); // "html"為HTML文本
}
//獲取編輯器中HTML內(nèi)容
function getEditorHTMLContents() {
 var oEditor = FCKeditorAPI.GetInstance("content");
 return(oEditor.GetXHTML(false));
}
// 獲取編輯器中文字內(nèi)容
function getEditorTextContents() {
 var oEditor = FCKeditorAPI.GetInstance("content");
 return(oEditor.EditorDocument.body.innerText);
}
// 設(shè)置編輯器中內(nèi)容
function SetEditorContents(ContentStr) {
 var oEditor = FCKeditorAPI.GetInstance("content") ;
 oEditor.SetHTML(ContentStr) ;
}
//向編輯器插入指定代碼 
function insertHTMLToEditor(codeStr){ 
  var oEditor = FCKeditorAPI.GetInstance( "content "); 
  if (oEditor.EditMode==FCK_EDITMODE_WYSIWYG){ 
    oEditor.InsertHtml(codeStr); 
  }else{ 
    return false; 
  } 
} 
//統(tǒng)計(jì)編輯器中內(nèi)容的字?jǐn)?shù) 
function getLength(){ 
  var oEditor = FCKeditorAPI.GetInstance( "content "); 
  var oDOM = oEditor.EditorDocument; 
  var iLength ; 
  if(document.all){ 
    iLength = oDOM.body.innerText.length; 
  }else{ 
    var r = oDOM.createRange(); 
    r.selectNodeContents(oDOM.body); 
    iLength = r.toString().length; 
  } 
  alert(iLength); 
} 
//執(zhí)行指定動作 
function ExecuteCommand(commandName){ 
  var oEditor = FCKeditorAPI.GetInstance( "content ") ; 
  oEditor.Commands.GetCommand(commandName).Execute() ; 
}

到此這篇關(guān)于使用Js獲取、插入和更改FCKeditor編輯器里的內(nèi)容的文章就介紹到這了,更多相關(guān)Js操作FCKeditor編輯器內(nèi)容請搜素腳本之家以前的文章或下面相關(guān)文章,希望大家以后多多支持腳本之家!

您可能感興趣的文章:
  • JS操作Fckeditor的一些常用方法(獲取、插入等)
  • JS集成fckeditor及判斷內(nèi)容是否為空的方法
  • js判斷FCKeditor內(nèi)容是否為空的兩種形式
  • FCKeditorAPI 手冊 js操作獲取等
  • fckeditor常用Js,獲取fckeditor內(nèi)容,統(tǒng)計(jì)fckeditor字?jǐn)?shù),向fckeditor寫入指定代碼
  • Js FCKeditor的值獲取和修改的代碼小結(jié)
  • javascript fckeditor編輯器取值與賦值實(shí)現(xiàn)代碼
  • FCKEditor常用Js代碼,獲取FCK內(nèi)容,統(tǒng)計(jì)FCK字?jǐn)?shù),向FCK寫入指定代碼
  • FCKeditor提供了一個完整的JavaScript API
  • javascript 獲取FCKeditor內(nèi)容
  • extjs fckeditor集成代碼
  • JSP 頁面中使用FCKeditor控件(js用法)
  • jsp fckeditor 上傳中文圖片亂碼問題的解決方法

標(biāo)簽:新疆 巴彥淖爾 漯河 青海 貴港 黑龍江 運(yùn)城 石嘴山

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《使用Js獲取、插入和更改FCKeditor編輯器里的內(nèi)容》,本文關(guān)鍵詞  使用,獲取,插入,和,更改,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《使用Js獲取、插入和更改FCKeditor編輯器里的內(nèi)容》相關(guān)的同類信息!
  • 本頁收集關(guān)于使用Js獲取、插入和更改FCKeditor編輯器里的內(nèi)容的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    主站蜘蛛池模板: 马尔康县| 滨海县| 科技| 定结县| 德格县| 天水市| 延川县| 师宗县| 玛纳斯县| 襄城县| 台湾省| 宣武区| 芦山县| 邢台市| 七台河市| 吉隆县| 苏州市| 瑞丽市| 呼伦贝尔市| 东源县| 久治县| 石台县| 河北省| 建宁县| 大城县| 和田市| 定安县| 武鸣县| 长海县| 信丰县| 行唐县| 沂水县| 郑州市| 南雄市| 高阳县| 淮安市| 淮北市| 长垣县| 长春市| 遵义市| 鄂州市|