get HTMLViewer JS Errors

Hey there,

do anyone knows a reliable class or extension plugin for the macOS HTMLViewer to retrieve JS Errors?
If there is any MBS Solution I would like to take it. :wink:

A much better solution would be to display the WebKit WebConsole (Inspector) is this possible out of the box, with plugins like MSB?

Patric Lee

There are a few ideas here you could explore :

The first example seems relatively easy to adapt to HTMLViewer, by assigning all relevant data to window.status, and catch in StatusChanged.

The built in controls the various OSes expose to limits what information we can get from them.
And they don’t expose things like javascrip errors etc

The “WebConsole” is not something we can “show” because the OS control doesn’t expose it in any way we could even ask it to show.

I’ve been using a lot of Javascript inside HTMLViewers and what I did was make a test system where I use a normal HTML file that can be debugged in Safari (and in IE11). When I’m not debugging, my Xojo app has a build script which pulls in the HTML file and cleans it up for use inside Xojo. This let me catch & fix perhaps 90% or more of my JavaScript bugs without having to use Xojo at all. In this case, I’m the sole author of the HTML/CSS/JavaScript so it works great. If you are using someone else’s code, this may not work.

For what it’s worth that’s exactly how I made HTML Edit and why it initially required CodeKit if you were going to modify the source.

Thanks for all your feedback guys!
Currently I will completely rebuilding my open source “Web”-Editor - with which I maintain all my html, js & php projects - on Cocoa base with new features and stuff, you know. That’s why I was interested in a decent way of handling JS errors to build an internal debug console from scratch. So thanks for all of your feedback.


i use an htmlviewer with justgage.js and raphael-2.1.4.min.js dynamically with htmlviewer. executejavascripte,
this work fine on desktop APP but not on web APP, error is:
Could not execute returned javascript: JustGage is not defined
Source: g1 = new JustGage({id: “g1”,value: 72,min: 0,max: 100,donut: true,gaugeWidthScale: 0.6,counter: true,hideInnerShadow: true});

html code to constant var htmlsource:

<!doctype html>

    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width">
    .container {
        width: 450px;
        margin: 0 auto;
        text-align: center;

    .gauge {
        width: 450px;
        height: 450px;

    a:hover.button {
        margin: 30px 5px 0 2px;
        padding: 7px 13px;

    <div class="container">
        <div id="g1" class="gauge"></div>
        <a href="#" id="g1_refresh">Random Refresh</a>
    <script type="text/javascript" src=""></script>
<script type="text/javascript" src=""></script>

    document.addEventListener("DOMContentLoaded", function(event) {
        g1 = new JustGage({
            id: "g1",
            value: 72,
            min: 0,
            max: 100,
            donut: true,
            gaugeWidthScale: 0.6,
            counter: true,
            hideInnerShadow: true

        document.getElementById('g1_refresh').addEventListener('click', function() {
            g1.refresh(getRandomInt(0, 100));


load code on webapp to htmlviewer open method:


action button code to change value on gauge object:

  dim strscript as String
  strscript="g1 = new JustGage({id: "+chr(34)+"g1"+chr(34)+",value: 72,min: 0,max: 100,donut: true,gaugeWidthScale: 0.6,counter: true,hideInnerShadow: true});"
  HTMLViewer1.ExecuteJavaScript (strscript)

thanks to help me if you can…:wink: