对象不支持对象IE 8

时间:2012-08-30 12:23:07

标签: javascript extjs minimize

当我想最小化一个extjs窗口时,它在IE8中不起作用。所有其他浏览器都很好。我得到的错误是指向其中的一行:

iframe.dom.hasOwnProperty

这是不适用于IE8的东西吗?

也有

iframe.dom.contentWindow.parentLostFocus();

IE中的错误只是说:对象不支持对象。不确定问题是什么。有人有想法吗?

这是焦点

iframe = Ext.get('iframe_{0}'.sprintf(item.itemId));
if(!iframe.dom.hasOwnProperty('contentWindow')) {
  return;
}

if(iframe !== null && iframe.dom && iframe.dom.contentWindow && iframe.dom.contentWindow.parentGotFocus) {
  context.trace('calling parentGotFocus in iframe {0}'.sprintf(item.itemId));
  iframe.dom.contentWindow.parentGotFocus();
} else {
  context.trace('function parentGotFocus not found in iframe {0}'.sprintf(item.itemId));
}
},

1 个答案:

答案 0 :(得分:6)

IE8及更少版本不支持DOM元素的hasOwnProperty()。如果iframe.dom是DOM节点对象,则IE8会抛出错误“对象不支持属性或方法”。为避免错误,请尝试替换:

iframe.dom.hasOwnProperty("property name");

使用:

Object.prototype.hasOwnProperty.call(iframe.dom,"property name");
相关问题