cqhydz 2009-05-02 20:18
浏览 223
已采纳

extjs内如果是from方式Fckeditor不能在ie6.0下使用

我发现在ie6.0下xtype:'form' Fckeditor好像使用不正常无法显示出来,但ff ie7都是正常的,人有知道解决的方法吗

Ext.onReady(function(){
    var win = new Ext.Window({
        title: 'Ext和Fckeditor结合示例',
        width: 800,
        height: 600,
                deferredRender:false,
                name:'fcktest',
        items:[{
                        xtype:'form',
                        items:[{
xtype:'textarea',
name:'fbContent',
id:'fbContent',
fieldLabel:'Content',
height:270,
listeners : {
  'render' : {
   fn : function(field) {
      
   var oFCKeditor = new FCKeditor( 'fbContent' ) ;
oFCKeditor.BasePath = '/FCKeditor/' ;
oFCKeditor.ToolbarSet = 'Sitecfg' ;
oFCKeditor.Width = '100%' ;
oFCKeditor.Height = '350' ;
oFCKeditor.ReplaceTextarea() ;


   },
   scope : this
  }
}
}]
                }]
    });
  
    win.show();

  • 写回答

1条回答 默认 最新

  • zhoujuan520 2009-05-02 22:57
    关注

    下面代码在火狐 ie6,ie7都测试通过

    脚本 a.js
    [code="js"]
    var sFCKeditorToolbar = 'Default';
    var sFCKeditorBasePath = '/ext-2.2-web/fckeditor/';//指定绝对路径工程名称+fck编辑器目录
    var sFCKeditorBaseHref = 'http://localhost:8080/ext-2.2-web/';//工程路径
    var sFCKeditorSkinPath = '/ext-2.2-web/fckeditor/editor/skins/office2003/';//皮肤路径
    Ext.form.FCKeditor = function(config) {
    Ext.form.FCKeditor.superclass.constructor.call(this, config);
    this.FCKid = 0;
    this.MyisLoaded = false;
    this.MyValue = '';
    };

    Ext.extend(Ext.form.FCKeditor, Ext.form.TextArea, {
    onRender : function(ct, position) {
    if (!this.el) {
    this.defaultAutoCreate = {
    tag : "textarea",
    style : "width:100px;height:60px;",
    autocomplete : "off"
    };
    }
    Ext.form.TextArea.superclass.onRender.call(this, ct, position);
    if (this.grow) {
    this.textSizeEl = Ext.DomHelper.append(document.body, {
    tag : "pre",
    cls : "x-form-grow-sizer"
    });
    if (this.preventScrollbars) {
    this.el.setStyle("overflow", "hidden");
    }
    this.el.setHeight(this.growMin);
    }
    if (this.FCKid == 0)
    this.FCKid = get_FCKeditor_id_value()
    setTimeout("loadFCKeditor('" + this.name + "');", 100);
    },
    setValue : function(value) {
    this.MyValue = value;
    if (this.FCKid == 0)
    this.FCKid = get_FCKeditor_id_value()
    FCKeditorSetValue(this.FCKid, this.name, value)
    Ext.form.TextArea.superclass.setValue.apply(this, [value]);
    },

    getValue : function() {
        if (this.MyisLoaded) {
            value = FCKeditorGetValue(this.name);
            Ext.form.TextArea.superclass.setValue.apply(this, [value]);
            return Ext.form.TextArea.superclass.getValue(this);
        } else {
            return this.MyValue;
        }
    },
    
    getRawValue : function() {
        if (this.MyisLoaded) {
            value = FCKeditorGetValue(this.name);
            Ext.form.TextArea.superclass.setRawValue.apply(this, [value]);
            return Ext.form.TextArea.superclass.getRawValue(this);
        } else {
            return this.MyValue;
        }
    }
    

    });
    Ext.reg('fckeditor', Ext.form.FCKeditor);

    function loadFCKeditor(element) {
    oFCKeditor = new FCKeditor(element);
    oFCKeditor.ToolbarSet = sFCKeditorToolbar;
    oFCKeditor.Config['SkinPath'] = sFCKeditorSkinPath;
    oFCKeditor.Config['PreloadImages'] = sFCKeditorSkinPath + 'images/toolbar.start.gif' + ';' + sFCKeditorSkinPath
    + 'images/toolbar.end.gif' + ';' + sFCKeditorSkinPath + 'images/toolbar.bg.gif' + ';' + sFCKeditorSkinPath
    + 'images/toolbar.buttonarrow.gif';
    oFCKeditor.BasePath = sFCKeditorBasePath;
    oFCKeditor.Config['BaseHref'] = sFCKeditorBaseHref;
    oFCKeditor.Height = 260;
    oFCKeditor.ReplaceTextarea();

    }
    function FCKeditor_OnComplete(editorInstance) {

    Ext.getCmp(editorInstance.Name).MyisLoaded = true;
    
    editorInstance.Events.AttachEvent('OnStatusChange', function() {
        Ext.getCmp(editorInstance.Name).setValue();
    })
    

    }
    var FCKeditor_value = new Array();
    function FCKeditorSetValue(id, name, value) {
    if ((id != undefined) && (name != undefined)) {
    if (value != undefined)
    FCKeditor_value[id] = value;
    else if (FCKeditor_value[id] == undefined)
    FCKeditor_value[id] = '';
    var oEditor = FCKeditorAPI.GetInstance(name);

        if (oEditor != undefined)
            oEditor.SetData(FCKeditor_value[id])
    }
    

    }
    function FCKeditorGetValue(name) {
    if ((id != undefined) && (name != undefined)) {
    var oEditor = FCKeditorAPI.GetInstance(name);
    data = '';
    if (oEditor != undefined)
    data = oEditor.GetData()
    return data;
    }
    }
    var FCKeditor_id_value;
    function get_FCKeditor_id_value() {
    if (!FCKeditor_id_value) {
    FCKeditor_id_value = 0;
    }
    FCKeditor_id_value = FCKeditor_id_value + 1;
    return FCKeditor_id_value;
    }

    Ext.onReady(function() {
    var fckeditorFormPanel = new Ext.FormPanel({
    labelWidth : 35,
    title : 'fckeditor Form',
    width : 850,
    defaultType : 'textfield',
    items : [{
    xtype : 'fckeditor',
    name : 'n_context',
    id : 'n_context',
    fieldLabel : '内容',
    height : 400
    }]
    });
    fckeditorFormPanel.render(document.body);
    });

    [/code]

    页面 a.html
    [code="html"]
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">


    a.html
        <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
        <meta http-equiv="description" content="this is my page">
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="ext-2.2/resources/css/ext-all.css">
        <link href="fckeditor/_samples/sample.css" rel="stylesheet" type="text/css" />
        <script type="text/javascript" src="ext-2.2/adapter/ext/ext-base.js"></script>
        <script type="text/javascript" src="ext-2.2/ext-all.js"></script>
        <script type="text/javascript" src="fckeditor/fckeditor.js"></script>
        <script type="text/javascript" src="a.js">
        </script>
    </head>
    <body>
    </body>
    

    [/code]

    项目路径大概如下
    ext-2.2-web
    --src
    --WebRoot
    ----ext-2.2
    ----fckeditor
    ----WEB-INF
    ----a.html
    ----a.js

    程序运行截图
    [img]http://yourgame.iteye.com/upload/picture/pic/36245/35d4b828-6874-3aea-a557-b668036d2e49.gif[/img]
    [url]http://yourgame.iteye.com/upload/picture/pic/36245/35d4b828-6874-3aea-a557-b668036d2e49.gif[/url]
    火狐

    [img]http://yourgame.iteye.com/upload/picture/pic/36247/6e61826c-882a-3907-bb9a-f15742b92e6c.gif[/img]
    [url]http://yourgame.iteye.com/upload/picture/pic/36247/6e61826c-882a-3907-bb9a-f15742b92e6c.gif[/url]
    IE7

    [img]http://yourgame.iteye.com/upload/picture/pic/36249/96c43189-afc9-324d-8821-fb1ea67bf51b.gif[/img]
    [url]http://yourgame.iteye.com/upload/picture/pic/36249/96c43189-afc9-324d-8821-fb1ea67bf51b.gif[/url]
    ie6

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵