Article ID: 194227 - View products that this article applies to.
This article was previously published under Q194227
This article has been archived. It is offered "as is" and will no longer be updated.
Expand all | Collapse all

On This Page

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

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

Frame1.htm

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

Frame2.htm

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

Frame3.htm

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

References

For more information about the technologies discussed in this article, please refer to the documentation in the MSDN Online Web Workshop:
MSDN Library

Properties

Article ID: 194227 - Last Review: November 2, 2013 - Revision: 4.0
Applies to
  • Microsoft Internet Explorer 4.01 Service Pack 1
Keywords: 
kbnosurvey kbarchive kbhowto kbscript KB194227

Give Feedback

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com