Script error notification is not sent to Exec method of WebBrowser Host
This article was previously published under Q317024 On This PageSYMPTOMS
When you write a WebBrowser control host in Visual C++, you may use the information in the following Microsoft Knowledge Base article to generate notification of script errors: 261003 (http://support.microsoft.com/kb/261003/) How to handle script errors as a WebBrowser control host
However, this notification may be inconsistent: In both Internet Explorer 5.5 and Internet Explorer 6.0, the host may receive the notification on certain installations but not on others. Or, on Microsoft Windows platforms with Internet Explorer 5.5 installed, you may not receive the first notification, yet all subsequent notifications properly trigger the call to the Exec method.
CAUSE
This behavior is by design in Internet Explorer 6.0. The OLECMDID_SHOWSCRIPTERROR command ID does not fire if the Disable Script Debugging check box is cleared (on the Tools menu, click Internet Options, and then click Advanced). The behavior is a bug in Internet Explorer 5.5 that was resolved in Internet Explorer 6.0. For additional information about this issue, click the following article number to view the article in the Microsoft Knowledge Base: 263100 (http://support.microsoft.com/kb/263100/)
OL2000: Hyperlink does not open a new instance of your Internet browser
RESOLUTION
Although you can programmatically configure the registry setting behind the Disable Script Debugging check box, this affects the behavior of Internet Explorer and all other WebBrowser hosts on the computer, not just your WebBrowser host. Fortunately, you can guarantee that the OLECMDID_SHOWSCRIPTERROR message fires on every computer, regardless of configuration, by injecting a script-based onerror event handler into the current document. This can be done from your host's DWebBrowser2::DocumentComplete() event handler. For additional information about how to sink events in both Microsoft Foundation Classes (MFC) and the Active Template Library (ATL), click the following article number to view the article in the Microsoft Knowledge Base: 247073 (http://support.microsoft.com/kb/247073/)
CustWBC.exe: ATL HTML control customizes the WebBrowser control
For a sample application that demonstrates how to sink events for Internet Explorer from an MFC application, visit the following MSDN Web site:
http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/browser/MFCIEEvtSpy/default.asp (http://msdn.microsoft.com/archive/default.asp?url=/archive/en-us/samples/internet/browser/MFCIEEvtSpy/default.asp)
The following sample code was written for an MFC dialog box application; the body can be cut and pasted, along with the macros, into either an ATL or MFC host:
STATUSThis behavior is by design. MORE INFORMATIONSteps to reproduce the problem
| Article Translations
|
Back to the top
