关于document、window、Element在浏览器的表现:
alert(typeof window); //chorme Object IE Object
alert(typeof Element); //chorme function IE Object
alert(typeof document); //chorme Object IE Object
可以看到Element和window在IE中都是Object类型的。
老版本IE 的 DOM Element 是没有 hasOwnProperty 方法的。
还有 window 对象也没有 hasOwnProperty 方法。
可以考虑用 Object 对象的 hasOwnProperty 试试。
Object.prototype.hasOwnProperty.call(window, "property")
Object.prototype.hasOwnProperty.call(element, "property")
本文探讨了在不同浏览器环境中,如IE与Chrome中,DOM元素如document、window及Element类型的实现差异,并特别指出老版本IE中DOM Element缺乏hasOwnProperty方法的问题。
2457

被折叠的 条评论
为什么被折叠?



