reTextarea("content")函數---FCKEditor編輯器使用例子,fckeditor編輯器

來源:互聯網
上載者:User

reTextarea("content")函數---FCKEditor編輯器使用例子,fckeditor編輯器

引入fckeditor編輯器入口檔案

<chtml file="editors/fckeditor/fckeditor.htm" />

如果會話中使用者ID(user_id)為空白(未登入),則臨時設一個ID,方便上傳檔案(圖片等)

<if x="@{session:user_id}">    <session><we name=user_id>0</we></session></if>

要替換的文本域(Textarea)

<Textarea name="content" id="content"><a href="http://edoit.htok.net" target=_blank>輕鬆互連網開發平台</a></Textarea>

引入FCKEditor編輯器的指令碼

setFCKHeight(300);//編輯器高度//setFCKTool("Coder");//setFCKTool("Basic");window.onload = reTextarea("content");//用函數 reTextarea() 建立編輯器並替換文本域(Textarea),預設文本網域名稱稱為"content"

重寫內容的函數

doReset = function (){    //document.getElementById('Edoit_Form').reset();    FCKeditorAPI.GetInstance('content').SetHTML("");}

提交的函數

doSubmit = function (){    //var tit = document.getElementById('title');    //if(tit.value=="" || tit.value=="問題:")    //{alert("有問題就提唄,不要客氣嘛!");tit.focus();return;}    var oEditor = FCKeditorAPI.GetInstance('content');    var oDOM = oEditor.EditorDocument;    var des;    if(document.all)        // If Internet Explorer.        des = oEditor.EditorDocument.body.innerText;    else{                   // If Gecko.        var r = oDOM.createRange();        r.selectNodeContents(oDOM.body);        des = r.toString();    }    des = des.Trim();    if(des=="")    {alert("沒有內容啊,寫點唄!");return;}    var frm = document.getElementById("Edoit_Form");    frm.submit();}

效果

完整代碼

<html><head><title>FCKEditor編輯器使用例子,reTextarea("content")</title></head><body><h3>FCKEditor編輯器使用例子,reTextarea("content")</h3><!-- 引入fckeditor編輯器入口檔案 --><chtml file="editors/fckeditor/fckeditor.htm" /><!-- 如果會話中使用者ID(user_id)為空白(未登入),則臨時設一個ID,方便上傳檔案(圖片等) --><chtml><if x="@{session:user_id}">    <session><we name=user_id>0</we></session></if></chtml><!-- 提交的表單 --><form id="Edoit_Form" method="post" action="@{sys:path}@{sys:curPath}editor_fck_save.chtml"><!-- 添加您需要的其他欄位 --><input name="title" value="您的標題" style="display:none" /><!-- 要替換的文本域(Textarea) --><Textarea name="content" id="content"><a href="http://edoit.htok.net" target=_blank>輕鬆互連網開發平台</a></Textarea><!-- 引入FCKEditor編輯器的指令碼 --><script type="text/javascript">setFCKHeight(300);//編輯器高度//setFCKTool("Coder");//setFCKTool("Basic");window.onload = reTextarea("content");//用函數 reTextarea() 建立編輯器並替換文本域(Textarea),預設文本網域名稱稱為"content"//重寫內容的函數doReset = function (){    //document.getElementById('Edoit_Form').reset();    FCKeditorAPI.GetInstance('content').SetHTML("");}doSubmit = function (){    //var tit = document.getElementById('title');    //if(tit.value=="" || tit.value=="問題:")    //{alert("有問題就提唄,不要客氣嘛!");tit.focus();return;}    var oEditor = FCKeditorAPI.GetInstance('content');    var oDOM = oEditor.EditorDocument;    var des;    if(document.all)        // If Internet Explorer.        des = oEditor.EditorDocument.body.innerText;    else{                   // If Gecko.        var r = oDOM.createRange();        r.selectNodeContents(oDOM.body);        des = r.toString();    }    des = des.Trim();    if(des=="")    {alert("沒有內容啊,寫點唄!");return;}    var frm = document.getElementById("Edoit_Form");    frm.submit();}</script><p><center><input type=reset name=reset value=重寫 onClick="doReset()" />&nbsp;&nbsp;<input type="button" value="提交" onClick="doSubmit()" /></center></p></form></body></html>

(例子檔案:_samples/editor/editor_fck_reTextarea.html)在輕開平台的_samples/editor目錄下

相關資源下載:
移動App應用伺服器開發從入門到精通:http://download.csdn.net/detail/tx18/8741611
快速搭建移動App伺服器 :http://download.csdn.net/detail/tx18/8737507
輕開平台會不定期升級為大家提供更多強大而Easy的功能,請留意下載最新的版本:http://download.csdn.net/user/tx18
開發執行個體:輕開B2C電子商務網站,免費下載:http://download.csdn.net/detail/tx18/8318585

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.