473,749 Members | 2,432 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

AxWebBrowser & Hide Javascript error windows

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!
Nov 15 '05 #1
3 10414
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********@hot mail.com> wrote in message
news:O0******** *****@TK2MSFTNG P11.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 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!

Nov 15 '05 #2
why not try set WebBrowser Silent to true?
"Alvin Bruney" <vapordan_spam_ me_not@hotmail_ no_spamhotmail. com> wrote in
message news:e0******** *****@TK2MSFTNG P11.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********@hot mail.com> wrote in message
news:O0******** *****@TK2MSFTNG P11.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 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!


Nov 15 '05 #3
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
3041
by: Gary Varga | last post by:
In the file WebUIValidation.js, when a postback that doesn't fail the validation has a javascript error saying summary is undefined in the ValidationSummaryOnSubmit function. Page_ValidationSummaries has a length of 1 but there are no array entries. This is the line that fails: summary.style.display = "none";
4
1885
by: Ian Cox | last post by:
I have a web form that contains a Datagrid. This grid has a number of columns, one of which contains a text box and validator for that text box. Everything works fine, when I press the "Save" button the validator works as expected...however... ....I want to hide certain columns under certain conditions. One of the columns I wish to hide is the column that contains the text box and the validator. This is done by something like ...
14
25635
by: Rich | last post by:
I am converting my enterprise solution from VS 2003 (.NET v1.1.4322) to VS 2005 (.NET v2.0.50727). The entire solution uses serveral technologies - Windows Server 2003 (AD, SQL Server 2000, IIS, ASP.NET, ASP.NET Mobile) Windows Mobile 2003 (Pocket IE) I have completed a portion of the conversion (ASP.NET Mobile pages for PIE, and some of the ASP.NET-bases web services), and while testing I have a runtime error that did not exist in the...
0
1179
by: news.microsoft.com | last post by:
I am going crazy trying to figure this out, and I am wondering if this is a bug in the ASP.Net implementation. My situation: I have an ASPX page with 2 different modes: *Mode 1: Datagrid with no footer *Mode 2: Datagrid with a footer template containing a textbox and an "Add Record" command (also has an edit column)
0
1186
by: Chris S | last post by:
I am going crazy trying to figure this out, and I am wondering if this is a bug in the ASP.Net 1.1 implementation. My situation: I have an ASPX page with 2 different modes: *Mode 1: Datagrid with no footer *Mode 2: Datagrid with a footer template containing a textbox and an "Add Record" command (also has an edit column)
1
1345
by: Josh | last post by:
I'm trying to trigger an onSubmit function from a form using Javascript. As far as I know the only way to do this is to hide a submit button and then use 'button'.click() on the submit button to fire the onSubmit event. Unfortunately I'm getting a permissions Javascript error, has anyone experienced this before and fixed it? Thanks.
2
6646
by: ZeeHseez | last post by:
Hi, I have written a webbrowser application in VB .net Framework 1.1. I would like to suppress javascript error messages. However, the silent property of the webbrowser control suppresses the Javascript messages, but it also blocks any other dialog box, such as Login dialog, i can't use the silent property. I used http://support.microsoft.com/default.aspx?scid=kb;EN-US;279535 article to suppress the error messages. It works fine until a...
47
65392
by: SOLAV | last post by:
This is the only working way to completely hide your JavaScript code from the client just like PHP or ASP code. Here we'll need the help of PHP. Here is the code: index.php ________________________________________________________ <?PHP @session_start(); //Start our session. if(@!session_is_registered('PrintTheJavaScript')){ //If the session is not registered (and it's not). @session_register('PrintTheJavaScript'); //Register the...
4
2693
by: miraan | last post by:
Hi, I am getting a javascript error but my page works perfectly fine and nothing is wrong, how do i hide the javascript error pop up window that appears when you visit the web page?
0
8997
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8833
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9568
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9389
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9335
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9256
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8257
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6801
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4881
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.