Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: Document.Frames Collection Does Not Support For Each Syntax


View products that this article applies to.

This article was previously published under Q191184

↑ Back to the top


Symptoms

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

↑ Back to the top


Cause

The Document.Frames collection does not support the functionality required for the "For Each" syntax.

↑ Back to the top


Resolution

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>
				

↑ Back to the top


Status

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

↑ Back to the top


More information

Steps to Reproduce Behavior

  1. Save the following HTML as Frames.htm in a folder:
    <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>
    					
  2. Save the following HTML as Frame1.htm:
    <HTML>
      <HEAD>
      </HEAD>
      <BODY>
         FRAME 1
      </BODY>
    </HTML>
    					
  3. Save the following HTML as Frame2.htm:
    <HTML>
      <HEAD>
      </HEAD>
      <BODY>
         FRAME 2
      </BODY>
    </HTML>
    					
  4. Navigate to Frames.htm.
You will see the above mentioned error message.

↑ Back to the top


Keywords: kbbug, kbhtml, kbieobj, kbpending, kbscript, KB191184

↑ Back to the top

Article Info
Article ID : 191184
Revision : 2
Created on : 5/12/2003
Published on : 5/12/2003
Exists online : False
Views : 484