JavaScript獲取FCK編輯器的信息 – Javascript教程_JS教程_技術文章 – 程式設計聯盟

 

function getEditorContents(){ 

    var oEditor = FCKeditorAPI.GetInstance("content"); 

    alert(oEditor.GetXHTML(true)); 

//向編輯器插入指定代碼 

function insertHTMLToEditor(codeStr){ 

    var oEditor = FCKeditorAPI.GetInstance("content"); 

    if (oEditor.EditMode==FCK_EDITMODE_WYSIWYG){ 

     oEditor.InsertHtml(codeStr); 

    }else{ 

     return false; 

    } 

//統計編輯器中內容的字數 www.aiwalls.com

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); 

//執行指定動作 

function ExecuteCommand(commandName){ 

    var oEditor = FCKeditorAPI.GetInstance("content") ; 

    oEditor.Commands.GetCommand(commandName).Execute() ; 

//設置編輯器中內容 

function SetContents(codeStr){ 

    var oEditor = FCKeditorAPI.GetInstance("content") ; 

    oEditor.SetHTML(codeStr) ; 

 

 摘自 Lee.的專欄

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *