FCKeditor是一款非常優秀的在線HTML編輯器,功能強大,支持在線編輯HTML文件,上傳圖片和文件等功能。關于FCKeditor的安裝與配置你可以在本站中進行搜索或在百度等搜索引擎中進行搜索一下即可。本文僅講解如何設置和獲取FCKeditor中的內容。
獲取FCKeditor中的內容常有兩種需求:(1)獲取帶HTML格式符的內容;(2)獲取純文本不含HTML格式符的內容,下面直接給出源代碼。
// 獲取編輯器中HTML內容
function getEditorHTMLContents(EditorName) {
var oEditor = FCKeditorAPI.GetInstance(EditorName);
return(oEditor.GetXHTML(true));
}
// 獲取編輯器中文字內容
function getEditorTextContents(EditorName) {
var oEditor = FCKeditorAPI.GetInstance(EditorName);
return(oEditor.EditorDocument.body.innerText);
}
// 設置編輯器中內容
function SetEditorContents(EditorName, ContentStr) {
var oEditor = FCKeditorAPI.GetInstance(EditorName) ;
oEditor.SetHTML(ContentStr) ;
}
新聞熱點
疑難解答