.pause()
and reset currentTime
for HTML5 videos.src
to stop playback..pause()
on the iframe element.If $('#modal-video')[0].pause();
isn't stopping the video in your Webflow modal, it's likely because the method only works on HTML5 <video>
elements, not on embedded Vimeo or YouTube videos. Here's how to handle both types correctly.
<video id="modal-video" ...></video>
— pause()
should work.If you're using an HTML5 <video>
, but pause()
still doesn't work, try this:
Ensure jQuery is loaded (Webflow includes it by default).
Add this line in your modal close handler:
$('#modal-video')[0].pause(); $('#modal-video')[0].currentTime = 0;
This pauses and rewinds the video.
Webflow users often embed YouTube using an <iframe>
:
Use the src
reset method to stop playback:
$('#youtube-iframe').attr('src', $('#youtube-iframe').attr('src'));
This reloads the iframe, effectively stopping the video.
Alternatively: Use YouTube Player API for more control via JavaScript, which requires a more complex integration.
If the modal uses a Vimeo iframe:
Use the Vimeo Player API by adding this to your custom code:
Include Player SDK via CDN:
Add this inside your <head>
or before </body>
:<script src="https://player.vimeo.com/api/player.js"></script>
JavaScript Example:
```
var vimeoPlayer = new Vimeo.Player(document.getElementById('vimeo-iframe'));
vimeoPlayer.pause();
```
Make sure the iframe has an ID like vimeo-iframe
.
Always insert the custom code in Page Settings > Before
tag, or in the Embed element, depending on your setup.
Ensure it's inside a close
event function like:
$('.modal-close').on('click', function() { /* your code */ });
To stop a video after closing a modal in Webflow:
.pause()
and .currentTime = 0
for HTML5 videos.src = src
.Let me know the video type you're using for more precise instructions.