JSFiddle - React, Tailwind, and code Playground

by xibo

HTML

<h1>iframe test</h1>
  <div>history length <span id="historyLength"></span></div>
<div>
    <button id="deleteButton">remove iframe</button>
</div>
<iframe src="https://www.wikipedia.org/" frameborder="0" height="500" width="500">
    iframe
</iframe>

JavaScript

const button = document.getElementById('deleteButton');
const historyLength = document.getElementById('historyLength');

button.addEventListener('click', () => {
  const iframe = document.querySelector('iframe');
  document.body.removeChild(iframe);
})

setInterval(() => {
  historyLength.innerText = window.history.length;
}, 500);