How to stop or pause video embedded in iframe

Stop or pause video embedded in iframe

November 17, 2021

Code 💻

1 min read

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');