//這個例子 會列出葉面所有 物件 的 tagName
<html>
<body><form method="POST" action="--WEBBOT-SELF--">
<input type="text" name="T1" size="20">
<input type="submit" value="submit" name="B1">
<input type="reset" value="reset" name="B2">
</form>
</body>
<script language="javascript">
var strName ="";
for (var i=0;i<document.all.length;i++)
{
strName = strName + document.all(i).tagName + "\n";
}
alert(strName);
</script></html>
<html>
<body><form method="POST" action="--WEBBOT-SELF--">
<input type="text" name="T1" size="20">
<input type="submit" value="submit" name="B1">
<input type="reset" value="reset" name="B2">
</form>
</body>
<script language="javascript">
var strName ="";
for (var i=0;i<document.all.length;i++)
{
strName = strName + document.all(i).tagName + "\n";
}
alert(strName);
</script></html>
<input type=text value="第一个" name="aa123"><br>
<input type=submit value="第二个" name="bb456"><br>
<input type=reset value="第三个" name="cc789"><br>
</form>
<script>
str="";
for(i=0;i<document.forms[0].elements.length;i++)
{
str += document.forms[0].elements[i].name.substring(0,3)+"\n";
}
alert(str);
</script>