Microsoft KB Archive/191184

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

Article ID: 191184

Article Last Modified on 5/12/2003

-

APPLIES TO


 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2
 * Microsoft Internet Explorer 4.01 Service Pack 1
 * Microsoft Internet Explorer 5.0
 * Microsoft Internet Explorer 5.5

-



This article was previously published under Q191184



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



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



RESOLUTION
Use a regular FOR loop to enumerate through the Document.Frames collection. For example, if you had the following code:  Sub Window_OnLoad Dim f For Each f In Document.Frames MsgBox f.location.href Next End Sub  You can change this code to use the regular for loop syntax as follows:  Sub Window_OnLoad Dim i For i = 0 to document.frames.length - 1 MsgBox frames(i).location.href Next End Sub 



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



Steps to Reproduce Behavior
  Save the following HTML as Frames.htm in a folder:    Sub Window_OnLoad Dim f For Each f In Document.Frames MsgBox f.location.href Next End Sub  </HEAD>

<FRAMESET rows="50%,*"> <FRAME SRC="frame1.htm"></FRAME> <FRAME SRC="frame2.htm"></FRAME> </FRAMESET> </HTML> </li> <li> Save the following HTML as Frame1.htm: <HTML> <HEAD> </HEAD> <BODY> FRAME 1 </BODY> </HTML> </li> <li> Save the following HTML as Frame2.htm: <HTML> <HEAD> </HEAD> <BODY> FRAME 2 </BODY> </HTML> </li> <li>Navigate to Frames.htm.</li></ol>

You will see the above mentioned error message.

Keywords: kbbug kbscript kbieobj kbhtml kbpending KB191184

-

[mailto:TECHNET@MICROSOFT.COM Send feedback to Microsoft]

© Microsoft Corporation. All rights reserved.