HTML-MANIPULATOR

by velo_ninja

HTML

<script>
  var iframes;  // Declare iframes variable in the outer scope

  setTimeout(function() {
    iframes = document.querySelectorAll("iframe");
    console.log(iframes);
    var iframeId = iframes[0].getAttribute("id");
    console.log("Iframe ID:", iframeId);

    iframes[0].setAttribute("allow", "microphone; camera");

    //--------------------------------------------
    var y = iframes[0].parentNode;
    var x = iframes[0];
    x.setAttribute("allow", "microphone; camera");
    y.appendChild(x);
    //--------------------------------------------

    setTimeout(function() {
      xxx();
    }, 3000);
  }, 3000);

  function xxx() {
    console.log('xxx started...');
    if (iframes && iframes.length > 0) {
      // Accessing the contentWindow of the first iframe
      var iframeContentWindow = iframes[0].contentWindow;

      // Sending a simple string message to the iframe
      iframeContentWindow.postMessage("Hello, iframe!", "https://example.com");
    }
  }
</script>