PRB: Events Not Firing When IE4 WebBrowser Placed On Web Page

ID: Q183048


The information in this article applies to:


SYMPTOMS

WebBrowser events such as DocumentComplete, DownloadComplete, BeforeNavigate2, and others do not fire when you host the WebBrowser control in an HTML page under Internet Explorer 4.0x.


CAUSE

The WebBrowser ActiveX control is not designed to be used in an HTML OBJECT tag.


RESOLUTION

Microsoft does not support use of the WebBrowser control in an HTML OBJECT tag. Microsoft recommends using IFRAME or FRAMEs instead of embedding the WebBrowser control in HTML.


STATUS

This behavior is by design.


MORE INFORMATION

You cannot write Script event handlers for WebBrowser control events, such as DocumentComplete, BeforeNavigate2, and other events, when you host the WebBrowser control in an HTML page using the OBJECT tag. These events are not fired. These events are not fired even if the WebBrowser control is wrapped in another ActiveX control and then embedded in HTML.

If the reason for hosting the WebBrowser control in an HTML page is to display documents within your Web page, we recommend using the IFRAME tag.

Steps to Reproduce Behavior

  1. Type and save the following HTML as C:\Page1.htm.
    
    <HTML>
    <HEAD>
       <TITLE>WebBrowser Control in HTML</TITLE>
    </HEAD>
    <BODY>
    
    <SCRIPT LANGUAGE="VBScript">
    Sub WebBrowser1_BeforeNavigate2(pDisp, URL, Flags, _
          TargetFrameName,  PostData, Headers, Cancel)
       MsgBox "BeforeNavigate2"
    end sub
    
    Sub WebBrowser1_DocumentComplete(pDisp, URL)
       MsgBox "DocumentComplete"
    end sub
    
    Sub Window_OnLoad()
       WebBrowser1.Navigate "http://www.microsoft.com"
    End Sub
    </SCRIPT> 


  2. Navigate to C:\Page1.htm from Internet Explorer 4.0.


DocumentComplete and BeforeNavigate2 events are not fired


REFERENCES

For more information, please see the MSDN Web Workshop:

http://msdn.microsoft.com/workshop/default.asp

Additional query words:


Keywords          : kbcode kbIE400 kbIE401 kbIE500 AXSDKWebBrowser 
Version           : WINDOWS:4.0,4.01
Platform          : WINDOWS 
Issue type        : kbprb 

Last Reviewed: April 30, 1999