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