You are currently offline, waiting for your internet to reconnect

How To Refresh a Specific Frame from Script

This article was previously published under Q194227
This article has been archived. It is offered "as is" and will no longer be updated.
When creating Web pages that contain frames, you may wish to refresh thecontents of a specific frame in response to some user interaction, such asa button click. You can perform this action using the script included inthis article.

NOTE: Due to the cross-frame security model of Internet Explorer 4.0 andlater, this will work only if the Web pages contained within the frames areon the same domain as the one that includes the script to refresh theframe.
More information
Because the document object model of Internet Explorer does not contain arefresh method for frames, you can use the go method of the history objectin order to refresh the contents of a specific frame.

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


<HTML>   <FRAMESET COLS="20%,40%,40%">      <FRAME NAME="MAIN" SRC="frame1.htm">      <FRAME SRC="frame2.htm">      <FRAME SRC="frame3.htm">   </FRAMESET></HTML>				


<HTML><HEAD>   <SCRIPT Language="VBScript">      Sub RefreshBtn_onClick         If Text1.Value <> "" Then            set win = top.frames(Text1.Value - 1)            win.History.go 0         End If       End Sub   </SCRIPT></HEAD><BODY>   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>				


 <HTML> <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>				


<HTML><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>				
For more information about the technologies discussed in this article,please refer to the documentation in the MSDN Online WebWorkshop:

Article ID: 194227 - Last Review: 11/02/2013 21:00:00 - Revision: 4.0

Microsoft Internet Explorer 4.01 Service Pack 1

  • kbnosurvey kbarchive kbhowto kbscript KB194227