Microsoft KB Archive/194227

= How To Refresh a Specific Frame from Script =

Article ID: 194227

Article Last Modified on 7/2/2004

-

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 Q194227



SUMMARY
When creating Web pages that contain frames, you may wish to refresh the contents of a specific frame in response to some user interaction, such as a button click. You can perform this action using the script included in this article.

NOTE: Due to the cross-frame security model of Internet Explorer 4.0 and later, this will work only if the Web pages contained within the frames are on the same domain as the one that includes the script to refresh the frame.



MORE INFORMATION
Because the document object model of Internet Explorer does not contain a refresh method for frames, you can use the go method of the history object in order to refresh the contents of a specific frame.

To see how this works, copy the following HTML into the files specified and load Main.htm using Internet Explorer 4.0 or later. Then, Click Refresh in the leftmost frame. Each time one of the frames is loaded or unloaded, a message box shows you that the refresh operation was successful.

Main.htm
      

Frame1.htm
   Sub RefreshBtn_onClick If Text1.Value <> "" Then set win = top.frames(Text1.Value - 1) win.History.go 0 End If      End Sub  

 Enter the number of the frame to refresh.<BR/> Enter 2 for frame 2, 3 for frame 3.<BR/><BR/> <INPUT TYPE="Text" ID="Text1"><BR/> <BUTTON ID="RefreshBtn">Refresh</BUTTON> </BODY> </HTML>

Frame2.htm
 <SCRIPT LANGUAGE="VBScript"> Sub Window_onLoad MsgBox "Frame 2 is loading" End Sub

Sub Window_onUnload MsgBox "Frame 2 is unloading" End Sub </SCRIPT> <BODY> <H1>This is Frame 2</H1> </BODY> </HTML>

Frame3.htm
 <SCRIPT LANGUAGE="VBScript"> Sub Window_onLoad MsgBox "Frame 3 is loading" End Sub

Sub Window_onUnload MsgBox "Frame 3 is unloading" End Sub </SCRIPT> <BODY> <H1>This is Frame 3</H1> </BODY> </HTML>

<div class="references_section">