侧边栏壁纸
博主头像
秋码记录

一个游离于山间之上的Java爱好者 | A Java lover living in the mountains

  • 累计撰写 29 篇文章
  • 累计创建 40 个标签
  • 累计创建 185 个分类

Extjs 3.3 tree以下的版本在IE10无法点击的解决办法

距上篇文章已过去好几天了,说好的一周发表1到3篇文章,难道都让狗吃了吗?现在才发布一篇而且还是转载的文章。好了,闲话少叙,切入正题,Extjs前端框架是比较早的前端mvc框架了,可能很多人都没接触过,而且现在也很少有项目用Extjs框架搭建了,原因是什么?那就不得而知了,有人说是Extjs比较重……

距上篇文章已过去好几天了,说好的一周发表1到3篇文章,难道都让狗吃了吗?现在才发布一篇而且还是转载的文章。 好了,闲话少叙,切入正题,Extjs前端框架是比较早的前端mvc框架了,可能很多人都没接触过,而且现在也很少有项目用Extjs框架搭建了,原因是什么?那就不得而知了,有人说是Extjs比较重…… 在使用Extjs3.3及以下的版本,在IE10环境中却无法点击树节点,而在IE的其他版本(IE7,IE8,IE9,IE11)均可正常。经过在网上查找资料得知,原因是因为Extjs3.3的ext-all.js中的getAttribute方法不能兼容IE10出错引起。 以下是Extjs3.3的ext-all.js的getAttribute方法

getAttribute : Ext.isIE ? function(name, ns){

var d = this.dom,
type = typeof d[ns + ":" + name];

if(['undefined', 'unknown'].indexOf(type) == -1){
return d[ns + ":" + name];
}
return d[name];
} : function(name, ns){
var d = this.dom;
return d.getAttributeNS(ns, name) || d.getAttribute(ns + ":" + name) || d.getAttribute(name) || d[name];
},

Extjs3.4的ext-all.js的getAttribute方法

getAttribute: (function(){
var test = document.createElement('table'),
isBrokenOnTable = false,
hasGetAttribute = 'getAttribute' in test,
unknownRe = /undefined|unknown/;

if (hasGetAttribute) {

try {
test.getAttribute('ext:qtip');
} catch (e) {
isBrokenOnTable = true;
}

return function(name, ns) {
var el = this.dom,
value;

if (el.getAttributeNS) {
value = el.getAttributeNS(ns, name) || null;
}

if (value == null) {
if (ns) {
if (isBrokenOnTable && el.tagName.toUpperCase() == 'TABLE') {
try {
value = el.getAttribute(ns + ':' + name);
} catch (e) {
value = '';
}
} else {
value = el.getAttribute(ns + ':' + name);
}
} else {
value = el.getAttribute(name) || el[name];
}
}
return value || '';
};
} else {
return function(name, ns) {
var el = this.om,
value,
attribute;

if (ns) {
attribute = el[ns + ':' + name];
value = unknownRe.test(typeof attribute) ? undefined : attribute;
} else {
value = el[name];
}
return value || '';
};
}
test = null;
})(),

将3.4中的方法覆盖3.3的ext-all.js中,ie10中tree恢复正常。