Reputation: 6609
Is there a way to track error messages in a webBrowser control? For example, in Firefox or Internet Explorer, I can look at the console output for Javascript errors. Is there a way to track those errors from within the application?
Upvotes: 1
Views: 1328
Reputation: 40736
There are two related Microsoft KB articles:
Although these are related to unmanaged C++ code, you should be able to adopt these for the C# web browser control, too.
Another article suggests to subscribe to the onerror
event:
m_htmlDoc = (IHTMLDocument2)axWebBrowser1.Document;
HTMLWindowEvents2_Event onErrorEvent;
onErrorEvent = (HTMLWindowEvents2_Event)m_htmlDoc.parentWindow;
onErrorEvent.onerror += new
HTMLWindowEvents2_onerrorEventHandler(myHTMLWindowEvents2_onerror);
And finally, there is a similar SO posting related to Delphi.
Upvotes: 2
Reputation: 481
Later versions of IE have a developer toolbar but sadly its not quite as good as Firebug or Web Inspector but thankfully we do have Firebug lite (http://getfirebug.com/firebuglite) which can help out with most things.
Upvotes: 0
Reputation: 7449
use window.onerror event, something like
window.onerror=function(msg, url, linenumber){
alert('Error message: '+msg+'\nURL: '+url+'\nLine Number: '+linenumber)
return true
}
Upvotes: 2