One.
Document.all is a collection of all elements within a page. For example:
document.all (0) represents the first element within a page
Two.
Document.all can tell if the browser is IE
if (document.all) {
Alert ("is ie!");
}
Three.
You can also call the element by setting the id attribute (ID=AAAA) to an element, and then using DOCUMENT.ALL.AAAA
Four.
Case:
Code 1:
<input name=aaa value=aaa>
<input id=bbb value=bbb>
<script language=jscript>
Alert (Document.all.aaa.value)//value by name
Alert (Document.all.bbb.value)//value by ID
</script>
Code 2:
But often name can be the same (e.g., using a checkbox to take a number of user preferences)
<input name=aaa value=a1>
<input name=aaa value=a2>
<input id=bbb value=bbb>
<script language=jscript>
Alert (DOCUMENT.ALL.AAA (0). Value)//display A1
Alert (DOCUMENT.ALL.AAA (1). Value)//Display A2
Alert (DOCUMENT.ALL.BBB (0). Value)//This line of code will fail
</script>
Code 3:
Theoretically a page ID is not the same, if there are different tags have the same id
Document.all.id will fail, just like this:
<input id=aaa value=a1>
<input id=aaa value=a2>
<script language=jscript>
Alert (Document.all.aaa.value)//display undefined instead of A1 or A2
</script>
Code 4:
For a complex page (the code is very long, or the ID is automatically generated by the program), or a
JavaScript Beginners Write the program, it is likely that two tags have the same id.
In order to program without error, I recommend this way:
<input id=aaa value=aaa1>
<input id=aaa value=aaa2>
<input name=bbb value=bbb>
<input name=bbb value=bbb2>
<input ID=CCC value=ccc>
<input name=ddd value=ddd>
<script language=jscript>
Alert (document.all ("AAA", 0). Value)
Alert (document.all ("AAA", 1). Value)
Alert (document.all ("BBB", 0). Value)
Alert (document.all ("BBB", 1). Value)
Alert (document.all ("CCC", 0). Value)
Alert (document.all ("ddd", 0). Value)
</script>