FckEditor----赋值与操作

来源:互联网 发布:马克鳗windows破解版 编辑:程序博客网 时间:2024/05/16 13:03

FCKEditor的赋值和取值操作

1、获取编辑器中HTML内容

function getEditorHTMLContents(EditorName)

    
var oEditor = FCKeditorAPI.GetInstance(EditorName); 
    
return(oEditor.GetXHTML(true)); 
}


2、获取编辑器中文字内容(在博客发布时获取无html代码摘要使用)

function getEditorTextContents(EditorName)

    
var oEditor = FCKeditorAPI.GetInstance(EditorName); 
    
return(oEditor.EditorDocument.body.innerText); 
}


3、设置编辑器中内容

function SetEditorContents(EditorName, ContentStr)

    
var oEditor = FCKeditorAPI.GetInstance(EditorName) ; 
    oEditor.SetHTML(ContentStr) ; 
}

 获得焦点:

在JS里取值方法如下:
var checkContent =FCKeditorAPI.GetInstance("content").GetXHTML();
另外还要让编辑器获得焦点:

var oEditor = FCKeditorAPI.GetInstance('content');
oEditor.Focus();
注意这里的Focus()是大写
原创粉丝点击