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 用matlab写代码
  • ¥30 motoradmin系统的多对多配置
  • ¥15 求组态王串口自定义通信配置方法或代码?
  • ¥15 实验 :UML2.0 结构建模
  • ¥20 用vivado写数字逻辑实验报告撰写,FPGA实验
  • ¥15 为什么shp文件会有这种小方块?
  • ¥15 ecplise在连接数据库时显示加载驱动成功但是数据库连接失败
  • ¥15 visionmaster启动失败,提示为“机器不满足授权而被禁用”
  • ¥15 IDEA中圈复杂度如何具体设置
  • ¥50 labview采集不了数据