日期:2014-05-16  浏览次数:20466 次

extjs4 IE8下getEl为空或不是对象?
代码如下,功能很简单,就是显示指定url的图片,在firefox下是正常的,一到ie8下就报错,
错误出在
JScript code
Ext.getCmp('img_viewer_box').getEl().dom.src = imgurl;
这一句上,各位有什么好的结局方案?
JScript code

var imageWin;
///显示指定url的图片
function ShowImg(imgurl,imgtitle)
{
    //Ext.Msg.alert('Status',imgurl);
    if(!imageWin)
    {
        imageWin = new Ext.Window({
            title: imgtitle+' - '+imgurl,
            src: imgurl,
            height:400,
            width:536,
            //bodyStyle:'background-image:url('+imgurl+');background-repeat:no-repeat; background-attachment:scroll;',
            plain:false,
            maxinizable:true,
            closeAction:'hide',//"close"释放窗体所占内存,"hide"隐藏窗体
            closable:true,
            autoDestroy:true,
            layout:'fit',
            items:[{
                xtype: 'box', //或xtype: 'component',
                id:'img_viewer_box',
                autoEl: 
                {
                    tag: 'img',    //指定为img标签
                    src: imgurl    //指定url路径
                }
            }]
        });
    }
    else
    {
        Ext.getCmp('img_viewer_box').getEl().dom.src = imgurl;
        imageWin.setTitle(imgtitle+' - '+imgurl);
    }    
    if(imageWin.isHidden())
    {
        imageWin.show();
    }
}



------解决方案--------------------

用这种方式如何:
imageWin.get(0).update('<img border=0 src="'+imgurl+'">');

------解决方案--------------------
不知道楼主是如何使用的,我这里测试过IE8没问题。。
又或者说是你自己哪里没有把现象说出来吧

if(imageWin.isHidden())
{
imageWin.show();
}

看看楼主的代码应该是extjs3吧,好像没有isHidden()这个函数的吧
------解决方案--------------------
EXTJS4没有get函数,改成这样吧:
imageWin.items.itemAt(0).update('<img border=0 src="'+imgurl+'">');

探讨
firefox

imageWin.get is not a function