FIX: Navigating to Frame with Web Page Starts New Instance of Internet Explorer (195556)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 4.0
  • Microsoft Internet Explorer (Programming) 4.01
  • Microsoft Internet Explorer (Programming) 4.01 SP1

This article was previously published under Q195556

SYMPTOMS

If you have a page with frames, using Hyperlink.NavigateTo to navigate to a UserDocument in a frame that contains an HTML page causes the UserDocument to be opened in a new instance of Internet Explorer.

RESOLUTION

Set the SRC property of the frame element directly instead of using Hyperlink.NavigateTo.

STATUS

Microsoft has confirmed that this is a bug in Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 4.01 SP1. This bug was corrected in Microsoft Internet Explorer 5.

MORE INFORMATION

Steps to Reproduce Behavior

The following HTML code creates a Web page that initially contains UserDocument1.vbd in the left frame and UserDocument2.vbd in the right frame. (UserDocument2.vbd doesn't do anything useful.)

UserDocument1 contains a button that, when pressed, calls Hyperlink.NavigateTo to navigate to a new UserDocument in the right-hand frame. UserDocument1 also contains an edit box to accept a URL. Typing a URL in the edit box and pressing a command button, causes the URL to be loaded in the right-hand frame.

After the URL is loaded in the right-hand frame, pressing the button that loads a new UserDocument, causes that UserDocument to be loaded in a new instance of Internet Explorer.
<HTML>
<FRAMESET cols="50,*>
    <FRAME SRC="UserDocument1.vbd">
    <FRAME NAME="RightFrame" SRC="UserDocument2.vbd">
</FRAMESET>
</HTML>
				


Here is the Visual Basic source code that implements the UserDocument1.vbd:

Option Explicit

Private Sub cmdAddress_Click()
  UserDocument.Hyperlink.NavigateTo txtAddress.Text, , "RightFrame"
End Sub

Private Sub cmdVBD_Click()
UserDocument.Hyperlink.NavigateTo "UserDocument2.vbd", , "RightFrame"
End Sub
				

Resolution

Setting the SRC property of the frame element directly allows you to work around this problem and still obtain the same result.

Here is the Visual Basic code to implement this resolution:
Option Explicit


Private Sub cmdAddress_Click()
  NavigateInFrame txtURL.Text
End Sub

Private Sub cmdVBD_Click()
  NavigateInFrame "UserDocument2.vbd"
End Sub

Private Sub NavigateInFrame(strURL As String)
  ' Get a reference to the window that is hosting the frameset
  Dim win As HTMLWindow2
  Set win = Parent.Parent.parentWindow

  ' Get the document associated with the window
  Dim doc As HTMLDocument
  Set doc = win.document

  ' Get the frame element for "RightFrame" from the all collection
  Dim frmElem As HTMLFrameElement
  Set frmElem = doc.All("RightFrame")
  frmElem.src = strFilename
				


This source code first gets a reference to the window that is containing the frameset. Then it gets a reference to the document. Finally, it gets a reference to the frame element associated with "RightFrame." Then it sets the SRC property to the name of the VBD or the URL.

Modification Type:MajorLast Reviewed:10/16/2002
Keywords:kbBug kbie500fix KB195556