I don't know what the two IF statements do, but if I try to comment
out the first one(because I have no idea what a tagname is, the script
stops with error at the second IF statement.
Object doesn;t support this property or method: 'item(...).type'
------------------------------------
It sounds like you have it solved, but for future
reference, an Item in all (or in the "box" collection)
is an HTMLElement object. (An HTML tag.) You can
apply any properties that apply to the element. If
you don't have the IE DOM docs you should get
a copy. In it you can look up properties and methods.
One property common to all elements is tagName,
which is "B", "A", "DIV", etc.
So the first If in my sample checks whether the
current item is an INPUT tag. If so, it checks whether
the type is checkbox. The error is because when you
remove the check for INPUT, all items trigger the second
check. Since not all tags have a "type" property, an error
results when it reaches one that doesn't.
Another common use is for events. The example below
will show the tagName and ID for any item in the page
that the mouse hovers over, while also coloring that item
red. It then colors the item to white again when the mouse
leaves. The srcElement object is the HTML tag that triggered
event:
<HTML><HEAD>
<SCRIPT LANGUAGE="VBScript">
Sub document_onmouseover()
Label1.innerText = document.parentwindow.event.srcElement.tagname & " - " &
document.parentwindow.event.srcElement.ID
document.parentwindow.event.srcElement.style.backgroundcolor = "#FF0000"
End Sub
Sub document_onmouseout()
document.parentwindow.event.srcElement.style.backgroundcolor = "#FFFFFF"
End Sub
</SCRIPT>
</HEAD>
<BODY>
<B>bold text</B>
<DIV ID="Div1">divtext</DIV>
<P ID="p1">a paragraph</P>
<LABEL ID="Label1" STYLE="width: 200px; border-style: solid; border-color:
#AAAAAA;">
</BODY></HTML>