title: Javascript changing values inside a iframe
body: <p>I have my website</p>
  <p><strong><a href="http://www.aplicatii-iphone.ro" rel="nofollow noreferrer">www.aplicatii-iphone.ro</a></strong></p>
  <p>and another</p>
  <p><strong>page.html on localhost</strong></p>
  <pre><code>&lt;html&gt;
  &lt;head&gt;
  &lt;title&gt;Object References across Iframes&lt;/title&gt;
  
  &lt;script type=&quot;text/javascript&quot;&gt;
  
  window.onload = function(){
      var form = document.getElementById('testForm');
      form.testBtn.onclick = sendData;
  }
  
  function notify() {
      //alert('iframe loaded');
      var iframeEl = document.getElementById('ifrm');
      if ( iframeEl &amp;&amp; iframeEl.parentNode &amp;&amp; document.createElement ) {
          var newTxt = document.createTextNode('The iframe has loaded and your browser supports it\'s onload attribute.');
          var newPara = document.createElement(&quot;p&quot;);
          newPara.className = 'demo';
          newPara.appendChild(newTxt);
          iframeEl.parentNode.insertBefore(newPara, iframeEl);
      }
  }
  
  function sendData() { // to form inside iframed document
      // frames array method:
     // window.frames['ifrm'].document.forms['ifrmTest'].elements['display'].value = this.form.testEntry.value;
      var ifrm = document.getElementById('ifrm');
      var doc = ifrm.contentDocument? ifrm.contentDocument: ifrm.contentWindow.document;
      var form = doc.getElementById('search-input'); // &lt;------&lt;&lt; search input
      form.display.value = this.form.testEntry.value;
      form.submit();
  }
  
  // test in iframed doc
  var counter = 0;
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form id=&quot;testForm&quot; action=&quot;#&quot;&gt;
  &lt;p&gt;&lt;input type=&quot;text&quot; name=&quot;testEntry&quot; size=&quot;30&quot; value=&quot;[enter something]&quot; /&gt; &lt;input name=&quot;testBtn&quot; type=&quot;button&quot; value=&quot;Click Me&quot; /&gt;&lt;/p&gt;
  &lt;/form&gt;
  
  &lt;iframe name=&quot;ifrm&quot; id=&quot;ifrm&quot; src=&quot;http://www.aplicatii-iphone.ro&quot; onload=&quot;notify()&quot; width=&quot;900&quot;&gt;Sorry, your browser doesn't support iframes.&lt;/iframe&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  <p>And every time I press the button <kbd>Click Me</kbd>, I want that the state of <a href="http://www.aplicatii-iphone.ro" rel="nofollow noreferrer">www.aplicatii-iphone.ro</a> to be like a user searched for that value written in &quot;testEntry&quot; from outside of the iframe.</p>
  <p>I tried something there ... but I can't figure it out ... any help please?</p>
  <p>I took the example from here <a href="http://www.dyn-web.com/tutorials/iframes/refs.php" rel="nofollow noreferrer">http://www.dyn-web.com/tutorials/iframes/refs.php</a></p>