考虑这一超文本源代码:
<form id="foo1" name="x"> Form 1 </form>
<form id="foo2"> Form 2 </form>
你们可以看到,我们确定了两个论坛要素。
In Chrome, Safari and Firefox, both document.foo1
and document.foo2
return undefined
.
However, in IE and Opera, document.foo1
returns a reference to the corresponding FORM element, whereas document.foo2
returns undefined
.
Live demo: http://jsfiddle.net/zrmEm/2/
So, the first form does have its ID-named property in the document object, and the second form doesn t. And this difference is the result of adding the name
attribute to the first form.
现在,这种逻辑是什么? 这是一种众所周知的行为吗?