【问题标题】:object doesnt support object IE 8对象不支持对象 IE 8
【发布时间】:2012-08-30 12:23:06
【问题描述】:

当我想最小化一个 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));
}
},

【问题讨论】:

  • 什么是dom?我从来没有听说过 iframe 元素上的那个属性。
  • 好吧,也许这就是问题所在:P 我更新了问题

标签: javascript extjs minimize


【解决方案1】:

IE8 及更低版本不支持 hasOwnProperty() 用于 DOM 元素。如果iframe.dom 是DOM Node 对象,那么IE8 会抛出错误“对象不支持属性或方法”。为避免错误尝试替换:

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

与:

Object.prototype.hasOwnProperty.call(iframe.dom,"property name");

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-11-03
    • 2012-06-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-04-22
    相关资源
    最近更新 更多