D
dricks dr
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 NavigateComplete(object
sender,AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)
{
mshtml.IHTMLDocument2 doc;
doc = (mshtml.IHTMLDocument2)browser.Document;
mshtml.IHTMLWindow2 window=doc.parentWindow;
HTMLWindowEvents_Event ievent =(HTMLWindowEvents_Event)window;
ievent.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowError);
}
private void WindowError(string t, string i, int s)
{
//Console.WriteLine("Erreur trouvee");
mshtml.IHTMLDocument2 doc;
doc = (mshtml.IHTMLDocument2)browser.Document;
mshtml.IHTMLWindow2 window=doc.parentWindow;
((IHTMLEventObj)window.@event).returnValue=true;
}
But it does NOT works with websites with Frames.
So i tried to set the event handler on frames too, using :
private void NavigateComplete(object
sender,AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)
{
mshtml.IHTMLDocument2 doc;
doc = (mshtml.IHTMLDocument2)browser.Document;
int index = 0;
object o =index ;
object o2 =index ;
if (doc.frames.length>0)
{
for (int i=0;i<doc.frames.length;i++)
{
o=i;
IHTMLWindow2 frame = (IHTMLWindow2)doc.frames.item(ref o);
if (frame.frames.length>0)
{
for (int j=0;j<frame.frames.length;j++)
{
o2=j;
IHTMLWindow2 frame2 = (IHTMLWindow2)frame.frames.item(ref o);
HTMLWindowEvents_Event ievent3
=(HTMLWindowEvents_Event)frame2;
ievent3.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowError);
}
}
HTMLWindowEvents_Event ievent2 =(HTMLWindowEvents_Event)frame;
ievent2.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowError);
}
}
mshtml.IHTMLWindow2 window=doc.parentWindow;
HTMLWindowEvents_Event ievent =(HTMLWindowEvents_Event)window;
ievent.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowError);
}
(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
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 NavigateComplete(object
sender,AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)
{
mshtml.IHTMLDocument2 doc;
doc = (mshtml.IHTMLDocument2)browser.Document;
mshtml.IHTMLWindow2 window=doc.parentWindow;
HTMLWindowEvents_Event ievent =(HTMLWindowEvents_Event)window;
ievent.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowError);
}
private void WindowError(string t, string i, int s)
{
//Console.WriteLine("Erreur trouvee");
mshtml.IHTMLDocument2 doc;
doc = (mshtml.IHTMLDocument2)browser.Document;
mshtml.IHTMLWindow2 window=doc.parentWindow;
((IHTMLEventObj)window.@event).returnValue=true;
}
But it does NOT works with websites with Frames.
So i tried to set the event handler on frames too, using :
private void NavigateComplete(object
sender,AxSHDocVw.DWebBrowserEvents2_NavigateComplete2Event e)
{
mshtml.IHTMLDocument2 doc;
doc = (mshtml.IHTMLDocument2)browser.Document;
int index = 0;
object o =index ;
object o2 =index ;
if (doc.frames.length>0)
{
for (int i=0;i<doc.frames.length;i++)
{
o=i;
IHTMLWindow2 frame = (IHTMLWindow2)doc.frames.item(ref o);
if (frame.frames.length>0)
{
for (int j=0;j<frame.frames.length;j++)
{
o2=j;
IHTMLWindow2 frame2 = (IHTMLWindow2)frame.frames.item(ref o);
HTMLWindowEvents_Event ievent3
=(HTMLWindowEvents_Event)frame2;
ievent3.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowError);
}
}
HTMLWindowEvents_Event ievent2 =(HTMLWindowEvents_Event)frame;
ievent2.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowError);
}
}
mshtml.IHTMLWindow2 window=doc.parentWindow;
HTMLWindowEvents_Event ievent =(HTMLWindowEvents_Event)window;
ievent.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowError);
}
(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