473,847 Members | 1,428 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 10425
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
3044
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
1887
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
25649
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
1184
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
1194
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
1346
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
6648
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
65472
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
2697
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
10991
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...
1
10718
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
10347
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
9490
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
7888
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
7061
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5725
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5915
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.