Created
November 10, 2023 09:22
-
-
Save jleyva/55bbb772e4b54d4ec2fa5541a5e5acd1 to your computer and use it in GitHub Desktop.
Redirect to launch moodlemobile custom url scheme via parent of iframe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Redirect Page</title> | |
<script> | |
// Define the target URL | |
var targetURL = 'moodlemobile://link=https://master.mm.moodledemo.net/course/view.php?id=14'; | |
// Function to redirect the parent window | |
function redirectParent() { | |
// Check if the parent window exists | |
if (window.self !== window.top) {{ | |
// Redirect the parent window to the target URL | |
window.parent.location.href = targetURL; | |
} else { | |
// If the parent window doesn't exist, show an error message | |
alert('Parent window not found. Redirect failed.'); | |
} | |
} | |
// Call the redirectParent function when the page loads | |
window.onload = redirectParent; | |
</script> | |
</head> | |
<body> | |
<p>If you are not redirected, <a href="moodlemobile://link=https://master.mm.moodledemo.net/course/view.php?id=14">click here</a>.</p> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment