为什么在IE8中document.getElementById被认为是一个对象 [英] Why is document.getElementById considered an object in IE8
本文介绍了为什么在IE8中document.getElementById被认为是一个对象的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我注意到, document.getElementById
是Firefox和Chrome中的一个功能,而 typeof
认为它是一个对象IE8(至少)。
任何人都有一个想法为什么?
解决方案
p>
I noticed that document.getElementById
is a function in Firefox and Chrome, while typeof
considers it an object in IE8 (at least).
Anyone has an idea why?
解决方案
IE8 (attempts to) implement ECMAScript 3 where the typeof
operator result is implementation defined for host objects regardless if the object implements [[call]]. In ES5, callable host objects must return "function"
.
See the table in ECMAScript 3
Compare to ECMAScript 5.1 http://www.ecma-international.org/ecma-262/5.1/#sec-11.4.3
这篇关于为什么在IE8中document.getElementById被认为是一个对象的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文