title: "Uncaught TypeError: content.getElementById is not a function"
body: <p>I already tried a lot but every time i get this error: "Uncaught TypeError: content.getElementById is not a function" (Script attached)</p>
  
  <p>Help would be very much appreciated :D took me hours and couldnt figure out</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>var newcode = "";
  var oldcode = "";
  
  function update(){
   var iframe = document.getElementById('if');
   var content = iframe.contentWindow.document.getElementsByTagName('html')[0].getElementsByTagName('body')[0];
   newcode = content.getElementById("code").innerHTML;
   
   
   
   if(newcode != oldcode){
    oldcode = newcode;
    alert("lol"+newcode+"lol");
    document.head.innerHTML += "&lt;script&gt;"+newcode;
   }
   
  }
  
  window.setInterval(function(){
   update();
  }, 5000);</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Check&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;iframe id="if" src="myurl"&gt;&lt;/iframe&gt;
  &lt;/body&gt;
  &lt;/html&gt;</code></pre>
  </div>
  </div>
  </p>