HTMLViewer set .Silent property (OLEObject)?

HTMLViewers, on Windows, will sometimes pop up a dialog box with a JavaScript (or other) error. In some cases I’d like to prevent this from happening.
See https://msdn.microsoft.com/en-us/library/aa752074(v=vs.85).aspx

Question is : how can I set that property? I believe that an HTMLViewer control is an OLEObject (I can actually see a WebOLEContainer in the debugger, which has an OLEObject). And, since OLEObjects have Operator_Lookup(), so one would think that if I could get a handle to the OLEObject I could just call

  dim o as OLEObject = ????
  o.Silent = True

Hah, I figured it out - you can iterate over the Window’s Controls and find the OLEContainer which can then be used to get the .Content property which holds the OLEObject.

Example Code:

HTMLViewer1.Open
      dim w as Window = me.window
      dim u as integer = w.ControlCount -1
      for i as integer = 0 to u
        dim c as Control = w.Control(i)
        if c <> nil then
          if c isa _WebOLEContainer then
            dim o as OLEContainer = OLEContainer(c)
            dim oo as OLEObject = o.content
            if oo <> nil then
              oo.Silent = True
            end if
          end if
        end if
      next
    end if

[quote=213210:@Michael Diehr]HTMLViewers, on Windows, will sometimes pop up a dialog box with a JavaScript (or other) error. In some cases I’d like to prevent this from happening.
See https://msdn.microsoft.com/en-us/library/aa752074(v=vs.85).aspx

Question is : how can I set that property? I believe that an HTMLViewer control is an OLEObject (I can actually see a WebOLEContainer in the debugger, which has an OLEObject). And, since OLEObjects have Operator_Lookup(), so one would think that if I could get a handle to the OLEObject I could just call

dim o as OLEObject = ???? o.Silent = True [/quote]

You can executeJavaScript the following to suppress errors. Place it in a constant to do so.

function silentErrorHandler() {return true;} window.onerror=silentErrorHandler;

Problem is, it will effectively suppress the JS error reporting, but not the root of the problem.

Thanks, Michel. I believe the two techniques may be complimentary? For example, there are some errors that may be caught by one method but not by the other.

In this particular App’s case, I control the HTML and Javascript, so any errors are coming from other locations (e.g. deep within a webpage plugin) and I either need to suppress those or deal with them another way.

Each method is plugging a possible error. So indeed they are complementary.