fckeditor常用Js,獲取fckeditor內(nèi)容,統(tǒng)計fckeditor字數(shù),向fckeditor寫入指定代碼
更新時間:2010年08月08日 17:53:45 作者:
fckeditor常用Js,獲取fckeditor內(nèi)容,統(tǒng)計fckeditor字數(shù),向fckeditor寫入指定代碼
content相當于你例子中的FCKeditor1。
//獲取格式化的編輯器內(nèi)容
function getEditorContents(){
var oEditor = FCKeditorAPI.GetInstance(“content”);
alert(oEditor.GetXHTML(true));
}
//向編輯器插入指定代碼
function insertHTMLToEditor(codeStr){
var oEditor = FCKeditorAPI.GetInstance(“content”);
if (oEditor.EditMode==FCK_EDITMODE_WYSIWYG){
oEditor.InsertHtml(codeStr);
}else{
return false;
}
}
//統(tǒng)計編輯器中內(nèi)容的字數(shù)
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);
}
//執(zhí)行指定動作
function ExecuteCommand(commandName){
var oEditor = FCKeditorAPI.GetInstance(“content”) ;
oEditor.Commands.GetCommand(commandName).Execute() ;
}
//設置編輯器中內(nèi)容
function SetContents(codeStr){
var oEditor = FCKeditorAPI.GetInstance(“content”) ;
oEditor.SetHTML(codeStr) ;
}
復制代碼 代碼如下:
//獲取格式化的編輯器內(nèi)容
function getEditorContents(){
var oEditor = FCKeditorAPI.GetInstance(“content”);
alert(oEditor.GetXHTML(true));
}
//向編輯器插入指定代碼
function insertHTMLToEditor(codeStr){
var oEditor = FCKeditorAPI.GetInstance(“content”);
if (oEditor.EditMode==FCK_EDITMODE_WYSIWYG){
oEditor.InsertHtml(codeStr);
}else{
return false;
}
}
//統(tǒng)計編輯器中內(nèi)容的字數(shù)
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);
}
//執(zhí)行指定動作
function ExecuteCommand(commandName){
var oEditor = FCKeditorAPI.GetInstance(“content”) ;
oEditor.Commands.GetCommand(commandName).Execute() ;
}
//設置編輯器中內(nèi)容
function SetContents(codeStr){
var oEditor = FCKeditorAPI.GetInstance(“content”) ;
oEditor.SetHTML(codeStr) ;
}
您可能感興趣的文章:
相關文章
fckeditor常用Js,獲取fckeditor內(nèi)容,統(tǒng)計fckeditor字數(shù),向fckeditor寫入指定代碼
fckeditor常用Js,獲取fckeditor內(nèi)容,統(tǒng)計fckeditor字數(shù),向fckeditor寫入指定代碼2010-08-08Ueditor和CKeditor 兩款編輯器的使用與配置方法
這篇文章主要介紹了Ueditor和CKeditor 兩款編輯器的使用與配置方法,需要的朋友可以參考下2017-03-03頁面嵌入Windows Media Player播放器代碼需要注意的
在頁面中插入WMP確實是個令人頭疼的一件事。這里簡單的說明下,希望對需要朋友有所幫助。2010-07-07