Skip to content

Instantly share code, notes, and snippets.

@JuliaKiselyova
Created September 28, 2023 10:24
Show Gist options
  • Select an option

  • Save JuliaKiselyova/aa544f1a47e7cab378d9cdb0ca59214a to your computer and use it in GitHub Desktop.

Select an option

Save JuliaKiselyova/aa544f1a47e7cab378d9cdb0ca59214a to your computer and use it in GitHub Desktop.
Pause the video after closing the popup
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