從IE4開始IE的object model才增加了document.all[],來看看document.all[]的Description:
Array of all HTML tags in the document.Collection of all elements contained by the object.
IE’s document.all collection exposes all document elements.This array provides access to every element in the document.
οnclick="document.all['heading1'].align='left';" />
<input type="button" value="Align Center"
οnclick="document.all['heading1'].align='center';" />
<input type="button" value="Align Right"
οnclick="document.all['heading1'].align='right';" />
例1(這個可以讓你理解文檔中哪些是對象)
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Document.All Example</title>
<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" />
</head>
<body>
<h1>Example Heading</h1>
<hr />
<p>This is a <em>paragraph</em>. It is only a <em>paragraph.</em></p>
<p>Yet another <em>paragraph.</em></p>
<p>This final <em>paragraph</em> has <em id="special">special emphasis.</em></p>
<hr />
<script type="text/javascript">
<!--
var i,origLength;
origLength = document.all.length;
document.write('document.all.length='+origLength+"<br />");
for (i = 0; i < origLength; i++)
{
document.write("document.all["+i+"]="+document.all[i].tagName+"<br />");
}
//-->
</script>
</body>
</html>
document.all[0]=!
document.all[1]=HTML
document.all[2]=HEAD
document.all[3]=TITLE
document.all[4]=META
document.all[5]=META
document.all[6]=META
document.all[7]=META
document.all[8]=META
document.all[9]=META
document.all[10]=LINK
document.all[11]=LINK
document.all[12]=LINK
document.all[13]=!
document.all[14]=META
document.all[15]=META
document.all[16]=META
document.all[17]=META
document.all[18]=META
document.all[19]=META
document.all[20]=META
document.all[21]=!
document.all[22]=BODY
document.all[23]=FORM
document.all[24]=DIV
document.all[25]=INPUT
document.all[26]=!
document.all[27]=STYLE
document.all[28]=SCRIPT
document.all[389]=EM
document.all[390]=DIV
document.all[391]=HR
document.all[392]=P
document.all[393]=SCRIPT