不做浮躁的人
          正在行走的人...
          posts - 171,  comments - 51,  trackbacks - 0

          在彈出窗口上訪問編輯器:
          1、如何在編輯器中插入文本:

          前置約定:
          插件名:insertvariables
          插件位置:editor/plugins/insertvariables/

          //創建自己的命令,不采用FCKDialogCommand的目的是FCKDialogCommand使用的是fck的缺省布局。
          var InsertVariableCommand=function(){
          };
          InsertVariableCommand.prototype.Execute=function(){
          }
          //讓按鈕不能點擊。
          InsertVariableCommand.GetState=function() {
          ??????? return FCK_TRISTATE_OFF; }
          //打開彈出窗口
          InsertVariableCommand.Execute=function() {
          ??????? window.open('insertVariable.do', 'insertVariable', 'width=500,height=400,scrollbars=no,scrolling=no,location=no,toolbar=no');
          }
          //注冊命令:
          FCKCommands.RegisterCommand('Insert_Variables', InsertVariableCommand );
          //注冊按鈕
          var oInsertVariables = new FCKToolbarButton('Insert_Variables', 'insert variable');
          oInsertVariables.IconPath = FCKConfig.PluginsPath + 'insertvariables/variable.gif';
          FCKToolbarItems.RegisterItem( 'Insert_Variables', oInsertVariables );

          //插入變量的請求頁面:insertVariable.do
          <html><head> etc...
          <script language="javascript">
                  <!--
                  var variable            = null;
                  var FCK                 = window.opener.FCK;
                  function ok() {
                          if(variable != null) {
                                  FCK.Focus();
          ????????????????????????//只在ie中有效 var B = FCK.EditorDocument.selection.createRange(); B.text = variable; } window.close(); } //--> </script> </head> <body> etc.. <a href="#" onClick="variable='this is a test'; ok();">insert text</a> </body> </html>

          //在fckconfig.js文件中加入以下字段
          FCKConfig.Plugins.Add( 'insertvariables' ) ;
          FCKConfig.ToolbarSets["myToolbar"] = [
                  ['Bold','Italic','Underline'],['Insert_Variables']
          ] ;
          
          				2、關聯上下文菜單選項:
          將插件的command注冊到上下文菜單中:
          FCK.ContextMenu.RegisterListener( { AddItems : function( menu, tag, tagName ) { // 符合條件顯示:if ( tagName == 'IMG' && !tag.getAttribute( '_fckfakelement' ) )
          if ( tagName == 'SPAN' && tag._fckplaceholder ) { // 顯示分隔符
          menu.AddSeparator() ; // 需要注冊命令名,標題,以及圖片路徑。
          ???menu.AddItem( 'placeholder', FCKLang.PlaceholderDlgTitle, oPlaceholderItem.IconPath ) ; } }} );
          posted on 2007-04-10 20:21 不做浮躁的人 閱讀(1202) 評論(0)  編輯  收藏

          只有注冊用戶登錄后才能發表評論。


          網站導航:
           

          <2007年4月>
          25262728293031
          1234567
          891011121314
          15161718192021
          22232425262728
          293012345

          常用鏈接

          留言簿(9)

          隨筆分類(31)

          隨筆檔案(75)

          文章分類(1)

          文章檔案(3)

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          主站蜘蛛池模板: 讷河市| 博野县| 南靖县| 阿城市| 敦煌市| 岚皋县| 永清县| 广东省| 邳州市| 黄大仙区| 新邵县| 湘阴县| 铜鼓县| 连城县| 棋牌| 荥经县| 名山县| 青冈县| 仙游县| 页游| 阿克陶县| 九龙县| 兰坪| 玛沁县| 安阳市| 建瓯市| 芒康县| 巴彦县| 焦作市| 汉沽区| 蒙阴县| 三都| 驻马店市| 雷波县| 荃湾区| 江源县| 武夷山市| 芒康县| 青神县| 富宁县| 迭部县|