js如何获得FCKeditor控件的值

JavaScript021

js如何获得FCKeditor控件的值,第1张

利用Javascript取和设FCKeditor值也是非常容易的,如下:

// 获取编辑器中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)

}

这个多半是加载的先后顺序不一致造成的,你可以去看下最终生成的页面的html代码,确保是按照 先引用fckeditor.js 再是JS方法 最后是<script>insertPageStr()</script>的顺序。