Home  >  Article  >  Web Front-end  >  Specific method of obtaining FCK editor information using JavaScript_javascript skills

Specific method of obtaining FCK editor information using JavaScript_javascript skills

WBOY
WBOYOriginal
2016-05-16 17:29:051145browse
Copy code The code is as follows:

function getEditorContents(){
var oEditor = FCKeditorAPI.GetInstance( "content");
alert(oEditor.GetXHTML(true));
}
//Insert the specified code into the editor
function insertHTMLToEditor(codeStr){
var oEditor = FCKeditorAPI. GetInstance("content");
if (oEditor.EditMode==FCK_EDITMODE_WYSIWYG){
oEditor.InsertHtml(codeStr);
}else{
return false;
}
}
// Count the number of words in the content in the editor
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);
}
//Execute the specified action
function ExecuteCommand(commandName){
var oEditor = FCKeditorAPI.GetInstance("content");
oEditor.Commands.GetCommand(commandName).Execute();
}
//Set the content in the editor
function SetContents (codeStr){
var oEditor = FCKeditorAPI.GetInstance("content");
oEditor.SetHTML(codeStr);
}
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn