title: Javascript Delete dynamically created iframe element by class?
body: <p>I'm looking at winbox.js <a href="https://nextapps-de.github.io/winbox/" rel="nofollow noreferrer">https://nextapps-de.github.io/winbox/</a> to create some windows.
  I'm using the iframe feature to load some external content. When its loaded I want to remove a specific element from the loaded page.</p>
  <p>This is the code I'm using to create the iframe and attempt to delete the element.</p>
  <pre><code>&quot;iframe&quot;: function(){
  
        new WinBox(&quot;Groups&quot;, {
  
        url: &quot;/localwebpage&quot;,
        class: &quot;iframe&quot;
      });
                      
      console.log ( document.getElementById('winbox-1').contentWindow.document )
      document.getElementById('winbox-1').contentWindow.document.getElementById('toTop');
  
   },
  </code></pre>
  <p>When this is run the iframe opens loading the correct page, however I get:</p>
  <pre><code>Uncaught TypeError: Cannot read properties of undefined (reading 'document')
      at Object.iframe ((index):714)
      at HTMLDivElement.onclick ((index):314)
  </code></pre>
  <p>Line 714 is the console.log line.</p>
  <p>This is the HTML, <code>winbox-1</code> is the iframe and <code>toTop</code> is the element I want to remove.</p>
  <p><a href="https://i.stack.imgur.com/Wc68t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wc68t.png" alt="HTML" /></a></p>
  <p>How can I do this using plain javascript ?</p>
  <p>Thanks</p>