BUG: Document.Frames Collection Does Not Support For Each SyntaxID: Q191184
|
When you try to enumerate through the Frames collection from Document object using VBScript's "For Each" syntax, you get the following error message:
Error: Object doesn't support this property or method
The Document.Frames collection does not support the functionality required for the "For Each" syntax.
Use a regular FOR loop to enumerate through the Document.Frames collection. For example, if you had the following code:
<SCRIPT LANGUAGE=VBSCRIPT>
Sub Window_OnLoad()
Dim f
For Each f In Document.Frames
MsgBox f.location.href
Next
End Sub
</SCRIPT>
You can change this code to use the regular for loop syntax as
follows:
<SCRIPT LANGUAGE=VBSCRIPT>
Sub Window_OnLoad()
Dim i
For i = 0 to document.frames.length - 1
MsgBox frames(i).location.href
Next
End Sub
</SCRIPT>
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
<HTML>
<HEAD>
<SCRIPT LANGUAGE=VBSCRIPT>
Sub Window_OnLoad()
Dim f
For Each f In Document.Frames
MsgBox f.location.href
Next
End Sub
</SCRIPT>
</HEAD>
<FRAMESET rows="50%,*">
<FRAME SRC="frame1.htm"></FRAME>
<FRAME SRC="frame2.htm"></FRAME>
</FRAMESET>
</HTML>
<HTML>
<HEAD>
</HEAD>
<BODY>
FRAME 1
</BODY>
</HTML>
<HTML>
<HEAD>
</HEAD>
<BODY>
FRAME 2
</BODY>
</HTML>
Additional query words:
Keywords : kbhtml kbIE400bug kbIE401bug kbIEObj kbScript kbIE500bug
Version :
Platform :
Issue type : kbbug
Last Reviewed: April 9, 1999