BUG: NavigateComplete Event Does Not Fire When WebBrowser Is Invisible (269614)



The information in this article applies to:

  • Microsoft Internet Explorer (Programming) 5.5

This article was previously published under Q269614

SYMPTOMS

When you host an invisible WebBrowser control in your application, the NavigateComplete event does not fire after the first navigation. In addition, NavigateComplete does not navigate to another page when you use the navigate method. (This problem does not occur with Internet Explorer 5.01.)

RESOLUTION

To resolve this problem, rather than make the WebBrowser control invisible, you can position the WebBrowser control so that it does not display its user interface on its container window. To do this, you can set the Left property of the WebBrowser control equal to the negative of the control's Width property. Alternatively, you can put the WebBrowser control behind other controls in your application.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to Reproduce Behavior

  1. In Microsoft Visual Basic, create a new Standard EXE project.
  2. In the Toolbox, add a component reference to Microsoft Internet Control.
  3. Add a WebBrowser control, a text box, and three buttons to the default form, Form1.
  4. Copy the following code into the code module of Form1:
    Option Explicit
    Private Sub Command1_Click()
        WebBrowser1.Navigate2 Text1.Text
    End Sub
    
    Private Sub Command2_Click()
        WebBrowser1.Visible = Not WebBrowser1.Visible
    End Sub
    
    Private Sub Command3_Click()
        MsgBox WebBrowser1.LocationURL
    End Sub
    
    Private Sub Form_Load()
        WebBrowser1.Visible = False
        Text1.Text = "http://www.microsoft.com"
        Command1.Caption = "Navigate"
        Command2.Caption = "Make Visible"
        Command3.Caption = "Current_URL"
    End Sub
    
    Private Sub WebBrowser1_BeforeNavigate2(ByVal pDisp As Object, URL As Variant, Flags As Variant, TargetFrameName As Variant, PostData As Variant, Headers As Variant, Cancel As Boolean)
        MsgBox "BeforeNavigate Event"
    End Sub
    
    Private Sub WebBrowser1_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
        MsgBox "NavigateComplete Event" 
    End Sub
    					
  5. Press the F5 key to run the project.
  6. Click Navigate. Both the BeforeNavigate event message box and the NavigateComplete event message box appear.
  7. In the text box, type another URL such as http://msdn.microsoft.com. The message box for the BeforeNavigate event appears, but the message box for the NavigateComplete event does not.
  8. Click Make Visible to show the WebBrowser control, or click Current_URL. The current page remains at http://www.microsoft.com.

REFERENCES

For more information on the NavigateComplete event, see the following MSDN Web Workshop page: For more information about developing Web-based solutions for Microsoft Internet Explorer, visit the following Microsoft Web sites:

Modification Type:MajorLast Reviewed:5/11/2006
Keywords:kbBug kbpending kbSBNWorkshop kbWebBrowser KB269614