WebHTMLViewer - LoadPage


I have a web project.

  1. I authored a web page (included below) to load an external page in an iframe and tested it from localhost on my dev machine (works)
  2. my page contains some javascript to handle the onload event of the iframe - the code signs into that page (passing username and password, then submitting a form (works). — the page then redirects to some content on another page —
  3. the onload event of the iframe is again fired and clicks a button to launch a course (works)

I then take the code from my working sample page, and using Me.LoadPage(tHtml) load the page in a WebHTMLViewer. The onload events fires (I checked by placing an alert in the event to troubleshoot) - the alert fires but the other code does not fire. I suspect document.getElementById etc are bombing in the WebHTMLViewer:

The code is here (XXX’s replace sensitive data):

      function course_launch()
        var ifrm = document.getElementById("myframe");
        var doc = ifrm.contentDocument;
        if (doc.getElementById("sign-in-email"))
         // signs in user if page is signin page
          doc.getElementById("sign-in-email").value = "XXXXXXXX";
          doc.getElementById("sign-in-pass").value = "XXXXXXXX";
         // launches course, when course launch button is present
            var element = doc.querySelector("a[href*='/dashboard/student_view/']").click();
    <iframe src="https://www.XXXXXXXX.com/user/login?destination=c/XXXXXXXXXXXXX" id="myframe" width="100%" height="100%" onload="course_launch()">

I require a solution that can work as efficiently in xojo as in the test html file, whether using the WebHTMLViewer or not.

Truly grateful for any assistance.

Kind regards, Andrew