0
Answer

onerror event axWebrowser

Ask a question
bobstar

bobstar

20y
2.2k
1
Hello. I need a little help to get this thing finished. Im trying to catch js errors and the event works as expected. However I have created an event from doc.parentWindow but when it fires im unable to suppress it using a returnValue = true. Im navigating to an URI using axWebBrowser1.Navigate(txtURI.Text, ref nullObject, ref nullObjStr, ref nullObjStr, ref nullObjStr); My code: mshtml.CEventObj CEobj; mshtml.HTMLWindowEvents2_Event iEvent2; private void NavigateComplete(object sender, AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e) { mshtml.HTMLDocument doc; doc = (mshtml.HTMLDocument)axWebBrowser1.Document; iEvent2 = (mshtml.HTMLWindowEvents2_Event) doc.parentWindow; iEvent2.onerror += new mshtml.HTMLWindowEvents2_onerrorEventHandler(iEvent2_onerror); } When this iEvent2 fires: private void iEvent2_onerror(string description, string url, int line) { label1.Text = "Err"; CEobj = (mshtml.CEventObj)iEvent2 ; CEobj.returnValue = true; } As you can see im trying to set the returnValue = true but it stills opens a new window telling me that there's an error onm the page. How do I suppress that? I've read that returnValue = true should do it here: http://support.microsoft.com/?kbid=279535 Kind regards