Notice: This website is an unofficial Microsoft Knowledge Base (hereinafter KB) archive and is intended to provide a reliable access to deleted content from Microsoft KB. All KB articles are owned by Microsoft Corporation. Read full disclaimer for more details.

BUG: NavigateComplete Event Does Not Fire When WebBrowser Is Invisible


View products that this article applies to.

This article was previously published under Q269614

↑ Back to the top


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

↑ Back to the top


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.

↑ Back to the top


Status

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

↑ Back to the top


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.

↑ Back to the top


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:

↑ Back to the top


Keywords: KB269614, kbwebbrowser, kbsbnworkshop, kbpending, kbbug

↑ Back to the top

Article Info
Article ID : 269614
Revision : 5
Created on : 5/11/2006
Published on : 5/11/2006
Exists online : False
Views : 345