<body>
<div id= "AA">123456</div>
<input type= "button" value= "There is an error with document" onclick= "alert ( Document.aa.innerText); " />
<br />
<input type= "button" value= "There is no error with document.all." onclick= "alert ( Document.all.aa.innerText); " />
</body>
Run the above code.
If the Name property is set in the HTML tag corresponding to the A,form object, the Image object, and the Applet object, its value will be used as the property name of the document object, to refer to the corresponding object, and not to other objects.
In addition, input and so on, if as a child element of a form, it is wrong to refer to this object directly with InputName or document.inputname, you must use Formname.inputname reference, Otherwise, you can use InputName to refer to.
It should also be noted that there are many elements that are normally used without name.
If you want to reference an element with an ID, you can only refer to it with an ID or document.getelementbyid,document.all.id
But like such elements, so like <a href= "..." name= "linkname" id= "LinkId" >......</a>
can use
Linkid.href;
Linkname.href;
Document.all.linkid.href;
Document.all.linkname.href;
document.getElementById ("LinkId"). href;
Document.getelementsbyname ("linkname") [0].href to reference
All is a collection that contains all the sets of HTML pairs, writing a program that can be accessed to all the image pairs. Like this:
<script language= "JavaScript" >
var obj= "";
for (i=0;i<document.all.length;i++)
Obj+=document.all[i].tagname+ ";";
alert (obj);
</script>
Note that you have to put the program after