feat: handle iframe navigation for course pages

Added an event handler to detect when the iframe loads a course page and redirect the parent window to the course URL. This ensures users are taken directly to course content, enhancing navigation and user experience.
This commit is contained in:
Kumi 2024-09-23 08:28:35 +02:00
parent 85d50e19b8
commit 476606f22f
Signed by: kumi
GPG key ID: ECBCC9082395383F

View file

@ -54,6 +54,16 @@
modalIframe.css("width", "100%");
modalIframe.css("height", "100%");
modalIframe.css("border", "none");
// Add event handler to iframe load events
modalIframe[0].addEventListener("load", function () {
const newLocation = modalIframe[0].contentWindow.location.href;
// If the iframe now contains a course page, open it in the parent window
if (newLocation.includes("/course/view.php?id=")) {
window.top.location.href = newLocation;
};
});
});
var scriptId = "script-" + Math.random().toString(36).substring(2, 9);