问题描述
我知道, getElementsByName
是在 HTMLDocument
和 HTMLDocument
继承自文档
和文档
继承自 Node
。
为什么我可以在Chrome中看到 Document.prototype.getElementsByName
而不是Firefox?没有Chrome实现DOM2规范?
是的,可能不是。我猜他们至少实现了,如果不是 : - )
但是,这些没有定义 getElementsByName
。那么他们是怎么得到的呢它实际上是在HTML5中指定的()上的文件
:
Yeah, probably not. I'd guess they at least implement DOM 3, if not a more current version :-)
However, those don't define a getElementsByName
either. So how did they get this? It is actually specified in HTML5 (WHATWG/W3) on the Document
partial interface:
And at http://dev.w3.org/html5/spec-LC/dom.html#documents-in-the-dom I found the note
So the specification details of these interfaces are still in progress, and varying. WebIDL does.
So Chrome does follow the newer specs (but still has some HTMLDocument
?), while Firefox implements an older version. However, it only really matters that these methods do exist on every window.document
- not how they got there :-)
这篇关于为什么Chrome中存在Document.prototype.getElementsByName?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!