title: Error:Domains, protocols and ports must match <br/> Error: "Object [object global] do not have method 'getElementsByTagName'"
body: <p>I am using NODE JS module with which I am creating a HTTP server. Server's response is a page containing JavaScript which embed a webpage in <code>&lt;iframe&gt;</code> and within this <code>&lt;iframe&gt;</code> I am accessing its elements data with <code>getElementsByTagName</code>.
  <br/>
  Here is response code:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;script type='text/javascript'&gt;
      function test() {
          document.body.innerHTML='&lt;iframe id="ifool" src="file:///C:/Users/Naman/Desktop/rew.htm" sandbox="allow-same-origin allow-forms allow-scripts"&gt; &lt;/iframe&gt;';
          var c;                 
          window.setInterval(function(){
          c=document.getElementById("ifool").contentWindow.location.href; 
          window.history.pushstate(0,0,c);  
          },100);
          window.setInterval(function () {
          var x = document.getElementById("ifool");
          var y = (x.contentWindow || x.contentDocument);
          if (y.document) y = y.document;
          try {
              var a = y.getElementsByTagName("input")[0].value;
              var b = y.getElementsByTagName("input")[1].value;
          } catch (err) {
              txt = "There was an error on this page.\n\n";
              txt += "Error description: " + err.message + "\n\n";
              txt += "Click OK to continue.\n\n";
              alert(txt);
          }
          }, 2000);
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body onload= 'test()'&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>I am getting error here as "Object [object global] do not have method 'getElementsByTagName'". I am using Chrome with this but I also tried Firefox.
  <br/></p>
  
  <p>In inspect element console I also getting following error-</p>
  
  <pre><code>localhost: Unsafe JavaScript attempt to access frame with URL "URL1" from frame with URL http://localhost:8080/. Domains, protocols and ports must match.
  </code></pre>