The document.all property is an array of all the HTML elements that are in the document.
The elements appear in the array in the order in which they were created.
翻译一下:
document.all 属性是一个 document 中所有(all)的 HTML 元素组成的数组。这些元素根据它们创建的顺序出现在数组中。
体验一下以下代码:

程序代码:
<html name='theHTML'>
<a name='theA'><h2 name='theH2'><u name='theU'>Paint Colors</u></h2></a>
Red<br name='1stBR'>
Green<br>
Blue<br>
Orange<br>
<hr>
<script name='theSCRIPT' language='JavaScript'>
for(var i=0; i<document.all.length; i++){
alert(document.all[i].name)
}
</script>
</html>
思考一下为什么从第一个 theHTML 到 theA 出现中间有若干个 undefined (未定义的)?
答案是:尽管你中间没有代码,但是浏览器认为有默认代码的。哪它们又该是什么呢?这留给楼主去思考。想一下一般 html 第一行的下一行是什么?答案应该很容易。
我的建议是:使用 【英文google】。体会是,No English, No JavaScript.