Extjs 简单扩展 Component 实现点击刷新的验证码。


view plaincopy to clipboardprint?
Ext.Image=Ext.extend(Ext.Component,{  
    initComponent:function()  
    {  
          
    },  
    onRender:function(ct, position)  
    {  
        var a= document.createElement('A');  
        a.id = this.id;a.href="javascript:void(0)";  
        var el = document.createElement('IMG');  
        el.src=this.src+'?'+Math.random();  
        a.appendChild(el);  
        this.el = Ext.get(ct.dom.appendChild(a));  
        if(this.autoRefresh)  
            this.el.on('click', this.onClick, this);  
    },  
    onClick: function(e){  
        this.el.first().dom.src=this.src+'?'+Math.random();  
    }  
})  
Ext.reg('ximg',Ext.Image); 
Ext.Image=Ext.extend(Ext.Component,{
initComponent:function()
{

},
onRender:function(ct, position)
{
var a= document.createElement('A');
a.id = this.id;a.href="javascript:void(0)";
var el = document.createElement('IMG');
el.src=this.src+'?'+Math.random();
a.appendChild(el);
this.el = Ext.get(ct.dom.appendChild(a));
if(this.autoRefresh)
this.el.on('click', this.onClick, this);
},
onClick: function(e){
this.el.first().dom.src=this.src+'?'+Math.random();
}
})
Ext.reg('ximg',Ext.Image);

以下是json
view plaincopy to clipboardprint?
{  
    xtype:'ximg',  
    src:'http://www.java125.cn/common/getcode.asp',  
    autoRefresh:true 

你可能感兴趣的:(JavaScript,json,ext,asp)