小男孩‘自慰网亚洲一区二区,亚洲一级在线播放毛片,亚洲中文字幕av每天更新,黄aⅴ永久免费无码,91成人午夜在线精品,色网站免费在线观看,亚洲欧洲wwwww在线观看

分享

【精華】FCKeditorAPI 手冊(cè)

 CevenCheng 2013-06-25

FCKeditorAPI 手冊(cè)

  1. function abc()    
  2.   {    
  3.    var checkContent =FCKeditorAPI.GetInstance("editor");//獲取實(shí)例    
  4.    alert(checkContent.GetXHTML());//獲取當(dāng)前內(nèi)容    
  5.    var newelement = document.createElement("a");    
  6.    newelement.href="#";    
  7.    newelement.innerHTML="df";    
  8.    checkContent.InsertElement(newelement);//前部添加元素(無(wú)返回值)    
  9.    var a=checkContent.InsertElementAndGetIt(newelement);//前部添加元素(返回元素)    
  10.    checkContent.InsertHtml("")//添加html    
  11.    checkContent.SetHTML("",true);//設(shè)置內(nèi)容,后為bool,是否所見(jiàn)即所得    
  12.      
  13.   }    
  14.   function aaa()    
  15.   {    
  16.   var checkContent =FCKeditorAPI.GetInstance("editor");//獲取實(shí)例    
  17.   checkContent.SwitchEditMode();//轉(zhuǎn)變編輯模式    
  18.   checkContent.UpdateLinkedField();//更新關(guān)聯(lián)文件    
  19.   }    
  20. function FCKeditor_OnComplete( checkContent )//當(dāng)加載完    
  21.   {    
  22.    alert( checkContent.Name ) ;    
  23.   }    
  24.   
  25. //設(shè)置fckeditor為只讀    
  26. function FCKeditor_OnComplete(editorInstance)    
  27.     {    
  28.         editorInstance.EditorDocument.body.disabled = true;    
  29.         editorInstance.EditorWindow.parent.document.getElementById          ('xExpanded').style.display = 'none';    
  30.         editorInstance.EditorWindow.parent.document.getElementById('xCollapsed').style.display = 'none';    
  31.         editorInstance.EditorWindow.blur();    
  32. }    
  33.   
  34. //向編輯器插入指定代碼    
  35. function insertHTMLToEditor(codeStr){    
  36.   var oEditor = FCKeditorAPI.GetInstance("content");    
  37.   if (oEditor.EditMode==FCK_EDITMODE_WYSIWYG){    
  38.     oEditor.InsertHtml(codeStr);    
  39.   }else{    
  40.     return false;    
  41.   }    
  42. }    
  43. //統(tǒng)計(jì)編輯器中內(nèi)容的字?jǐn)?shù)    
  44. function getLength(){    
  45.   var oEditor = FCKeditorAPI.GetInstance("content");    
  46.   var oDOM = oEditor.EditorDocument;    
  47.   var iLength ;    
  48.   if(document.all){    
  49.     iLength = oDOM.body.innerText.length;    
  50.   }else{    
  51.     var r = oDOM.createRange();    
  52.     r.selectNodeContents(oDOM.body);    
  53.     iLength = r.toString().length;    
  54.   }    
  55.   alert(iLength);    
  56. }    
  57. //執(zhí)行指定動(dòng)作    
  58. function ExecuteCommand(commandName){    
  59.   var oEditor = FCKeditorAPI.GetInstance("content") ;    
  60.   oEditor.Commands.GetCommand(commandName).Execute() ;    
  61. }    
  62. //設(shè)置編輯器中內(nèi)容    
  63. function SetContents(codeStr){    
  64.   var oEditor = FCKeditorAPI.GetInstance("content") ;    
  65.   oEditor.SetHTML(codeStr) ;    
  66. }    
  67.   
  68. //使用FCKEditor時(shí)使用js在光標(biāo)處添加任意字符串    
  69. function InsertHTML(e,inStr)//e:FCKEditor的ID,inStr:要插入的信息    
  70. {    
  71.         var oEditor = FCKeditorAPI.GetInstance(e) ;    
  72.        if ( oEditor.EditMode == FCK_EDITMODE_WYSIWYG )    
  73.           {    
  74.            oEditor.InsertHtml( inStr ) ;    
  75.         }    
  76.          else    
  77.             alert("You must be on WYSIWYG mode!" ) ;    
  78.     }    
  79.   
  80.     function ExecuteCommand( commandName,e )    
  81.      {    
  82.          var oEditor = FCKeditorAPI.GetInstance(e) ;    
  83.          oEditor.Commands.GetCommand(commandName ).Execute() ;    
  84.     } 


Commands 的定義:
\fckeditor\editor\js\fckeditorcode_ie.js

自定義 Commands 實(shí)戰(zhàn): 自定義我們的打開(kāi)圖片選擇對(duì)話框的命令?。。?/span>

step1 : 注冊(cè)我們自己定義的 Commands    "JSCallbackCommand"
查找 “|InsertHorizontalRule” 然后再后面插入 "|JSCallbackCommand"   

step2:定義我們的 JSCallbackCommand  【直接 copy 現(xiàn)有的 FCKDialogCommand 再做修改即可】
var FCKJSCallbackCommand=function(A,B,C,D,E,F,G,H){
this.Name=A;
this.Title=B;
this.Url=C;
this.Width=D;
this.Height=E;
this.CustomValue=H;
this.GetStateFunction=F;
this.GetStateParam=G;
this.Resizable=false;
};FCKJSCallbackCommand.prototype.Execute=function(fileUrl){
try
{
FCKDialog.OpenDialog('FCKDialog_'+this.Name,this.Title,this.Url + '?preview=' + encodeURIComponent(fileUrl),this.Width,this.Height,this.CustomValue,null,this.Resizable);
} catch(e){
alert(e);
}
};FCKJSCallbackCommand.prototype.GetState=function(){if (this.GetStateFunction) 
return this.GetStateFunction(this.GetStateParam);
else return FCK.EditMode==0?0:-1;};

step3 : 注冊(cè)進(jìn)事件處理   
查找 ";break;default:if (FCKRegexLib.NamedCommands.test(A)) B=new FCKNamedCommand(A);" 然后在 break; 前面插入:

case 'JSCallback':B=new FCKJSCallbackCommand('JSCallback',FCKLang.DlgImgTitle,'dialog/fck_image.html',450,390);


這樣,我們自定義的 JSCallbackCommand 就注冊(cè)完了?。?!

到時(shí)候可以通過(guò)  FCKEditorAPI 直接執(zhí)行該命令, 并且還可以傳遞參數(shù)。

調(diào)用示例:
var inst = FCKeditorAPI.GetInstance('HTMLeditor1');"
inst.Commands.GetCommand('JSCallback').Execute('http://a3.att.hudong.com/68/93/01300000556189125362932760553_140.jpg');"

結(jié)果就是,瀏覽器打開(kāi)一個(gè)彈出圖片dialog, 并且默認(rèn)選中了這張圖片


    本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購(gòu)買(mǎi)等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
    轉(zhuǎn)藏 分享 獻(xiàn)花(0

    0條評(píng)論

    發(fā)表

    請(qǐng)遵守用戶 評(píng)論公約

    類(lèi)似文章 更多