Microsoft KB Archive/156315

= How To Use VBScript to Control the Contents of Another Frame =

Article ID: 156315

Article Last Modified on 10/8/2003

-

APPLIES TO


 * Microsoft Visual Basic, Scripting Edition 1.1
 * Microsoft Visual Basic, Scripting Edition 2.0
 * Microsoft Internet Explorer 3.0
 * Microsoft Internet Explorer 3.01
 * Microsoft Internet Explorer 3.02
 * Microsoft Internet Explorer 4.0 128-Bit Edition
 * Microsoft Internet Explorer 4.01 Service Pack 2

-



This article was previously published under Q156315



SUMMARY
This article describes three methods for using Visual Basic, Scripting Edition, to alter the contents of another frame in the currently displayed frameset. Following are the three methods:


 * Locate the frame and write to its document object directly.
 * Change the HREF that the frame displays using LOCATION.HREF.
 * Change the HREF that the frame displays using NAVIGATE.

NOTE: All of these methods involve replacing what may already be displayed on a frame. If you want to replace just a portion of what is displayed, then you have to use an ActiveX control, which is placed on that page and designed for that purpose.

Also, please note that in Internet Explorer 4.0x, you cannot script across frames for pages that are on separate domains. For additional information, please see the following article in the Microsoft Knowledge Base:

167796 PRB: "Permission Denied" When Scripting Across Frames"



MORE INFORMATION
The first method of changing the content is to use DOCUMENT.WRITE. This allows you to create a page instantly without having an HTML file stored on the server. Remember to use DOCUMENT.CLOSE after writing to the other frame.

The second way of changing the content is to modify the LOCATION.HREF property. Changing this property for another frame causes the frame to load an HTML file stored on the server.

The third and final way is to use the NAVIGATE method. This works the same as modifying the LOCATION.HREF property, but calls a method instead.

All of these methods need to address a different frame than the current one. The example below demonstrates two ways to accomplish this. This first is to use the FRAMES collection, and the other is to use the name of the frame you want to change. In both cases, the parent document needs to be addressed first using WINDOW.PARENT.

To demonstrate how this works, create the following HTML pages and browse DEFAULT.HTM in Internet Explorer 3.0 or later. When you click on the buttons in the left frame, the content of the right frame changes.

Default.htm:
   

Left.htm:
        

Right.htm:
  This is a blank page in the right frame. </BODY> </HTML>

New.htm:
  This is a new page. </BODY> </HTML>

Keywords: kbscript kbfaq KB156315

-

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

© Microsoft Corporation. All rights reserved.