HtmlEditor :  Phorum 5 The fastest message board... ever.

This is the discussion forum for the HtmlEditor. See also the HtmlEditor home page, where you can download the control, and the Documentation Wiki, a collaborative project for documenting the control.

Goto Thread: PreviousNext
Goto: Forum ListMessage ListNew TopicSearchLog In
axWebBrowser and javascript errors
Posted by: Greg (---.tpgi.com.au)
Date: Friday, 02-Mar-2007, 02:55:51

hi all,

Has anyone come across working code for a Windows Forms application that uses AxWebBrowser control and is capable of intercepting and dealing with the 'Internet Explorer Script Error' (An error has occured in the script on this page') type errors. I know the WebBrowser control (the one that comes by default in Visual Studio Toolbox) has 'ScriptErrorsSuppressed' property that seems to achieve just that, but I don't have much time left for re-implementation.

After doing some searching on the web, some of the possible solutions that I've seen included:

1) setting aXWebBrowser.Silent = true at an appropriate time. The downside of this approach is that some of the pop-ups are useful, such as authentication prompts etc.

2) implementing IOleDocumentSite, IOleClientSite and IDocHostShowUI interfaces and using IDocHostShowUI:confused smileyhowMessage for the purpose of intercepting the message box. I have attempted this but am yet to see the ShowMessage function invoked...

3) implementing IOleCommandTarget and the QueryStatus and Exec methods, and then watching out for the Exec invocation with OLECMDID_SHOWSCRIPTERROR. From what I understand this behaviour doesn't work if Disable Script Debugging check box is cleared in Internet Explorer settings.

apologies that this post is not actually directly related to HtmlEditor :|

regards,
Greg

Re: axWebBrowser and javascript errors
Posted by: Brutuscat (---.fibertel.com.ar)
Date: Wednesday, 25-Apr-2007, 23:23:33

Yes, I've done it implementing IOleClientSite, IOleCommandTarget, IDocHostUIHandler. Then on the container control:

...
//In the constructor
object obj = browser.GetOcx();
IOleObject oleObj = obj as IOleObject;
oleObj.SetClientSite(this);

// Later, implementing the interfaces
public void IOleClientSite.GetContainer(ref object ppContainer)
{
ppContainer = this;
}

public int IOleCommandTarget.Exec(IntPtr pguidCmdGroup, int nCmdID, int nCmdExecOpt, IntPtr pvaIn, IntPtr pvaOut)
{
const int OLECMDID_SHOWSCRIPTERROR = 40;
switch(nCmdID)
{
case OLECMDID_SHOWSCRIPTERROR:
return 0;
default:
return 1;
}
}
...

All others methods must return 1 or null.



Your Name: 
Your Email: 
Subject: 
Spam prevention:
Please, enter the code that you see below in the input field. This is for blocking bots that try to post this form automatically.
W6PCV
This is a moderated forum. Your message will remain hidden until it has been approved by a moderator or administrator
This forum powered by Phorum.