Solved

Web browser control in a user control - problem!

Posted on 2004-09-03
4
3,993 Views
Last Modified: 2013-12-25
Hello,

I have developed a user control that contains the Web Browser control. I have put some code in the WebBrowser_DocumentComplete() event.

When I use this control in VB, and I call the Navigate method of the browser control (through a method of my user control), the WebBrowser_DocumentComplete() event is triggered (after the document download is complete) and my code there is executed.

However, when I use my control in an html page, the user control works fine, but when calling the Navigate method, the code does not execute. In fact, the WebBrowser_DocumentComplete() event is not triggered (entered) at all!

Does anyone know what is going wrong in the case of the html and how to solve this problem?
Please no workarounds (with timers), etc.

Please I want a solution, not only why the problem is happening (if you know why).

Thank you.
0
Comment
Question by:BigBoss
  • 2
4 Comments
 
LVL 11

Expert Comment

by:bingie
ID: 11978330
By HTML, you mean after navigating to a site? Is the Nav_Complete event fired?
0
 

Author Comment

by:BigBoss
ID: 11982292
bingie...thank you for your comment.
The DocumentComplete() event is an event of the WebBrowser control that is inserted inside my VB user control, and the VB user control is being used in HTML.
In the above case, the DocumentComplete() event of the WebBrowser control is not triggered, while it is triggered when my user control is used in a VB application.

I can not use the NaviagateComplete2() event because this event is triggered before the naviagtion is actually completed, while the DocumentComplete() event is triggered after everything in the HTML page have been downloaded to the browser.

Thanks again.
0
 

Accepted Solution

by:
BigBoss earned 0 total points
ID: 11995426
Well....I found it at last!
Here is what Microsoft says:

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

Q183048


--------------------------------------------------------------------------------
The information in this article applies to:

Microsoft Internet Explorer (Programming) versions 4.0, 4.01, 5.0

--------------------------------------------------------------------------------


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



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


DocumentComplete and BeforeNavigate2 events are not fired



REFERENCES
For more information on developing Web-based solutions for Internet Explorer, please see the following Web sites:


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

http://msdn.microsoft.com/ie/

http://support.microsoft.com/highlights/iep.asp?FR=0&SD=MSDN

Additional query words:

Keywords : kbcode kbIE400 kbie401 kbie500
Issue type : kbprb
Technology : kbIEsearch kbAudDeveloper kbSDKIESearch kbSDKIE400 kbSDKIE401


Last Reviewed: May 2, 1999
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.
 



--------------------------------------------------------------------------------
Send feedback to MSDN.Look here for MSDN Online resources.
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
VBA: Add rows to listbox based on criteria 7 73
How does CurrentUser work? 10 31
using web browser with BING 40 110
how to know if my Checkbox is True in VB6.0? 9 38
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now