title: calling javascript from js file
body: <p>I have elements on my parent page that changes only if hidden iframe within contain one div id.</p>
  
  <p>Everything is fine if I let code on html page :</p>
  
  <pre><code> &lt;iframe id="myiframe" style="display:none" onload="load()" name="myiframe"   src="mysite.com"&gt;&lt;/iframe&gt;
  </code></pre>
  
  <p>JavaScript:</p>
  
  <pre><code>function load(){
  
  
  if (window.frames[0].document.getElementById('applications'))
  {
  var str=document.getElementById("tst").innerHTML;
  var n=str.replace("Login","Logout");}}
  document.getElementById('tst').href='logout';
  </code></pre>
  
  <p>But I need iframe code deleted from html file and relocated js file.</p>
  
  <p>I use this code in js file to trigger iframe:</p>
  
  <pre><code>window.onload = function(){
  var link = "iframelink"
   var iframe = document.createElement('iframe');
  iframe.frameBorder=0;
  iframe.width="300px";
  iframe.height="250px";
  iframe.id="randomid";
  iframe.addEventListener("load", load);
  iframe.setAttribute("src", link);
  document.getElementById("ad54").appendChild(iframe);
  }
  </code></pre>
  
  <p>html code to get iframe:</p>
  
  <pre><code>&lt;div id="ad54"&lt;/div&gt;
  </code></pre>
  
  <p>Iframe launches, but right now I get no elements changed on parent page although iframe is triggered . When iframe is loaded I need those changes to take place in parent page.</p>