By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,165 Members | 853 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,165 IT Pros & Developers. It's quick & easy.

AxWebBrowser & Hide Javascript error windows

P: n/a
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_NavigateComple te2Event 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.WindowEr ror);
}

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_NavigateComple te2Event 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.WindowEr ror);
}
}

HTMLWindowEvents_Event ievent2 =(HTMLWindowEvents_Event)frame;
ievent2.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowEr ror);

}
}

mshtml.IHTMLWindow2 window=doc.parentWindow;
HTMLWindowEvents_Event ievent =(HTMLWindowEvents_Event)window;
ievent.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowEr ror);
}

(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!
Nov 15 '05 #1
Share this Question
Share on Google+
3 Replies


P: n/a
bad idea but you can hook into the window.error handler and swallow the
error. it's bad because everything gets swallowed. it's good for you because
it will get rid of the script errors.

"dricks dr" <dr********@hotmail.com> wrote in message
news:O0*************@TK2MSFTNGP11.phx.gbl...
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_NavigateComple te2Event 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.WindowEr ror);
}

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_NavigateComple te2Event 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.WindowEr ror);
}
}

HTMLWindowEvents_Event ievent2 =(HTMLWindowEvents_Event)frame;
ievent2.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowEr ror);

}
}

mshtml.IHTMLWindow2 window=doc.parentWindow;
HTMLWindowEvents_Event ievent =(HTMLWindowEvents_Event)window;
ievent.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowEr ror);
}

(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!

Nov 15 '05 #2

P: n/a
why not try set WebBrowser Silent to true?
"Alvin Bruney" <vapordan_spam_me_not@hotmail_no_spamhotmail.com > wrote in
message news:e0*************@TK2MSFTNGP11.phx.gbl...
bad idea but you can hook into the window.error handler and swallow the
error. it's bad because everything gets swallowed. it's good for you because it will get rid of the script errors.

"dricks dr" <dr********@hotmail.com> wrote in message
news:O0*************@TK2MSFTNGP11.phx.gbl...
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_NavigateComple te2Event 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.WindowEr ror);
}

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_NavigateComple te2Event 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.WindowEr ror);
}
}

HTMLWindowEvents_Event ievent2 =(HTMLWindowEvents_Event)frame;
ievent2.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowEr ror);

}
}

mshtml.IHTMLWindow2 window=doc.parentWindow;
HTMLWindowEvents_Event ievent =(HTMLWindowEvents_Event)window;
ievent.onerror+=new
HTMLWindowEvents_onerrorEventHandler(this.WindowEr ror);
}

(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!


Nov 15 '05 #3

P: n/a
Thanx for replying :)

@Alvin Bruney :
I dont understand what you mean with 'hook window error handler'. Could
you precise this please? It should be the right way to avoid those
annoying messages :)

@unknown user :
I can't use Silent=true property because it hides ALL message box,
including login//password message box of web sites, which is annoying :/

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 15 '05 #4

This discussion thread is closed

Replies have been disabled for this discussion.