Hi,
I'm using the AxWebBrowser Control from microsoft in a C# application.
It works fine, but i have many problems to hide the javascript error
windows that appear when u visit a website with... javascript errors :)
I can catch errors coming from website that does not use frames using :
private void NavigateComplet e(object
sender,AxSHDocV w.DWebBrowserEv ents2_NavigateC omplete2Event e)
{
mshtml.IHTMLDoc ument2 doc;
doc = (mshtml.IHTMLDo cument2)browser .Document;
mshtml.IHTMLWin dow2 window=doc.pare ntWindow;
HTMLWindowEvent s_Event ievent =(HTMLWindowEve nts_Event)windo w;
ievent.onerror+ =new
HTMLWindowEvent s_onerrorEventH andler(this.Win dowError);
}
private void WindowError(str ing t, string i, int s)
{
//Console.WriteLi ne("Erreur trouvee");
mshtml.IHTMLDoc ument2 doc;
doc = (mshtml.IHTMLDo cument2)browser .Document;
mshtml.IHTMLWin dow2 window=doc.pare ntWindow;
((IHTMLEventObj )window.@event) .returnValue=tr ue;
}
But it does NOT works with websites with Frames.
So i tried to set the event handler on frames too, using :
private void NavigateComplet e(object
sender,AxSHDocV w.DWebBrowserEv ents2_NavigateC omplete2Event e)
{
mshtml.IHTMLDoc ument2 doc;
doc = (mshtml.IHTMLDo cument2)browser .Document;
int index = 0;
object o =index ;
object o2 =index ;
if (doc.frames.len gth>0)
{
for (int i=0;i<doc.frame s.length;i++)
{
o=i;
IHTMLWindow2 frame = (IHTMLWindow2)d oc.frames.item( ref o);
if (frame.frames.l ength>0)
{
for (int j=0;j<frame.fra mes.length;j++)
{
o2=j;
IHTMLWindow2 frame2 = (IHTMLWindow2)f rame.frames.ite m(ref o);
HTMLWindowEvent s_Event ievent3
=(HTMLWindowEve nts_Event)frame 2;
ievent3.onerror +=new
HTMLWindowEvent s_onerrorEventH andler(this.Win dowError);
}
}
HTMLWindowEvent s_Event ievent2 =(HTMLWindowEve nts_Event)frame ;
ievent2.onerror +=new
HTMLWindowEvent s_onerrorEventH andler(this.Win dowError);
}
}
mshtml.IHTMLWin dow2 window=doc.pare ntWindow;
HTMLWindowEvent s_Event ievent =(HTMLWindowEve nts_Event)windo w;
ievent.onerror+ =new
HTMLWindowEvent s_onerrorEventH andler(this.Win dowError);
}
(ErrorWindow is still the same than before)
But it STILL doesn't work :(
Does someone know why it does not work?
How to fix this??
Help ! :)
F.Mestayer
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!