To stop HTML5 videos from continuing to play after a Webflow modal is closed, you need to reset the video element when the modal is hidden.
<script> const modal = document.getElementById("yourModalID"); const video = document.getElementById("myVideo"); modal.addEventListener("click", function(event) { if (event.target.classList.contains("w-modal-close")) { video.pause(); video.currentTime = 0; } });</script>
If you're using Webflow interactions to open/close modals:
Go to the Interactions panel.
On the element that triggers the modal to close, add a “Custom Code” action.
Use JavaScript like:
document.getElementById("myVideo").pause(); document.getElementById("myVideo").currentTime = 0;
This way the video is stopped and reset when the modal closes.
To stop videos from playing after a Webflow modal closes, pause and reset the video either with a custom JavaScript event listener or by using a Webflow interaction with custom code. Use the video’s ID to target it directly.