Hello,
I have a web project.
- 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)
- 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 —
- 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):
<html>
<head>
<script>
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";
doc.getElementById("user-login").submit();
}
else
{
// launches course, when course launch button is present
var element = doc.querySelector("a[href*='/dashboard/student_view/']").click();
}
}
</script>
</head>
<body>
<iframe src="https://www.XXXXXXXX.com/user/login?destination=c/XXXXXXXXXXXXX" id="myframe" width="100%" height="100%" onload="course_launch()">
</iframe>
</body>
</html>
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