Home > Web Front-end > JS Tutorial > body text

Specific method of obtaining FCK editor information using JavaScript_javascript skills

WBOY
Release: 2016-05-16 17:29:05
Original
1144 people have browsed it
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);
}
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template