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:
parent
85d50e19b8
commit
476606f22f
1 changed files with 10 additions and 0 deletions
10
script.js
10
script.js
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue