title: Get the value of a variable out of <iframe> or <object>
body: <p>In my global html template, I have embedded an <code>iframe</code>, which can live-preview <code>{{src}}</code> (eg, <code>src</code> could be <code>public/tmp/bDCZ5rynnpLaYNEuAAAj/index.html</code>).</p>
  
  <pre><code>&lt;iframe id="myiframe" ng-src="{{src}}"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>The <code>index.html</code> is a file written by my server; I have control of the code and I can modify it. <code>index.html</code> contains JavaScript code, it is designed such that it always has an internal variable <code>$output</code>.</p>
  
  <p>My question is, how to get the value of <code>$output</code> out of the <code>iframe</code> and let the global html page know the value.</p>
  
  <p>Does anyone know how to accomplish this?</p>
  
  <p><strong>Edit 1:</strong> I am also open to solutions where <code>index.html</code> could send the value to the server or create a file with the value, as long as the global template could get it later. Additionally, as I mention in comments, the purpose of <code>iframe</code> is to live-preview a folder of files, there are <a href="https://stackoverflow.com/questions/42569214/make-a-web-page-with-a-folder-of-external-files">other ways</a> to do so (eg, using <code>&lt;object&gt;</code>), does anyone know which way could let me get an internal value out?</p>
  
  <p><strong>Edit 2:</strong> I have made a <a href="https://plnkr.co/edit/5bByYqwrrzkslLK6Fnc2?p=preview" rel="nofollow noreferrer">plunker with iframe</a> and a <a href="https://plnkr.co/edit/uSik7MYblkTdTofu2v1B?p=preview" rel="nofollow noreferrer">plunker with object</a>. <code>$output</code> is defined by <code>&lt;script&gt;var $output="Default"&lt;/script&gt;</code> in <a href="https://www.matrixlead.com/tmp/indexOutput.html" rel="nofollow noreferrer">indexOutput.html</a>. My goal is to get this value out.</p>
  
  <p><strong>Edit 3:</strong> I just realised that <code>window.parent._resetter</code> that @Roy suggested in his answer works. But one thing is, the <code>_resetter</code> function must be defined in the script of the html page. Does anyone know how to <strong>pass this value to my controller</strong>? Here is <a href="https://plnkr.co/edit/Ak4mswbHeqKQZHl0zrUl?p=preview" rel="nofollow noreferrer">a plunker</a>, and <a href="https://plnkr.co/edit/Sp6uiPmLQIVQj3IWoJSa?p=preview" rel="nofollow noreferrer">a plunker with $window</a>.</p>