Created
September 28, 2023 10:24
-
-
Save JuliaKiselyova/aa544f1a47e7cab378d9cdb0ca59214a to your computer and use it in GitHub Desktop.
Pause the video after closing the popup
This file contains hidden or 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
| document.addEventListener("DOMContentLoaded", function () { | |
| // Get references to the video iframe and pop-up container | |
| const videoIframe = document.querySelector("#jet-popup-1950 iframe.jet-video-iframe"); | |
| const popUpContainer = document.querySelector("#jet-popup-1950 .jet-popup__container-content"); | |
| // Function to pause the video | |
| function pauseVideo() { | |
| videoIframe.contentWindow.postMessage('{"method":"pause"}', '*'); | |
| } | |
| // Add a click event listener to the entire document | |
| document.addEventListener("click", function (e) { | |
| // Check if the click occurred outside the pop-up container | |
| if (!popUpContainer.contains(e.target)) { | |
| // Pause the video when clicking outside the pop-up | |
| pauseVideo(); | |
| } | |
| }); | |
| }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment