How to stop or pause video embedded in iframe
Some tips that I found while trying to stop the embedded video with iframe.
November 16, 2021
By re-adding a src file to the element, it will reset the iframe element to original state.
javascript
1document.querySelectorAll('iframe').forEach((element) => {2 let iframeSrc = element.src;3 element.src = iframeSrc;4});
If there are any <video>
element that can be easily accessed, (no Cross Origin issues), then we can simply pause the video by:
javascript
1let videoElement = document.querySelector('video');23videoElement.pause();