title: How can I search iframe content (text) using an input field that is on the parent page?
body: <p>Yes, I know something like this has been asked over here before and I have searched but the one that is closest to what I'm trying to achieve doesn't have an answer ( <a href="https://stackoverflow.com/questions/19624594/search-iframe-content-with-jquery-and-input-element-on-parent-page">Search iframe content with jquery and input element on parent page</a> ) and the one that does is making use of nested iframes ( <a href="https://stackoverflow.com/questions/29910766/access-the-content-of-a-nested-iframe">Access the content of a nested Iframe</a> ) and I didn't quite understand the solution (VERY new with javascript so please bear with me). Honestly, it's getting a bit frustrating (it's quite late over here) so I thought I might as well ask.</p>
  
  <p>I have an iframe that displays a page from my site therefore the page is from the same domain. What I would like to do is to search the iframe for some text using javascript (not jquery). The search input box, however, is on the parent page.</p>
  
  <p>I've done something similar to this before by putting the search input box in the page displayed in the iframe instead ( I followed this tutorial: <a href="http://help.dottoro.com/ljkjvqqo.php" rel="nofollow noreferrer">http://help.dottoro.com/ljkjvqqo.php</a> ) but now I need to have the search input box on the <strong>parent page</strong> because I going to make it "sticky" so that it will follow the user as they scroll down the page. I've resized the parent page height to be the same as the length of the page in the iframe by also using javascript.</p>
  
  <p>So, my question is: <strong>How can I use javascript to search text that is in the iframe by using a search input box that is on the parent page?</strong></p>
  
  <p>My HTML so far:</p>
  
  <pre><code>        &lt;input type="text" name="page_no" size="3"/&gt;            
          &lt;input type="submit" name="goto" value="Go"/&gt;    
  
  &lt;iframe id='iframe2' src="http://example.com/files/&lt;?php echo $filename;?&gt;" frameborder="0" style="text-align:center; margin:0; width:100%; height:150px; border:none; overflow:hidden;" scrolling="yes" onload="AdjustIframeHeightOnLoad()"&gt;&lt;/iframe&gt;
          &lt;script type="text/javascript"&gt;
  function AdjustIframeHeightOnLoad() {    document.getElementById("iframe2").style.height = document.getElementById("iframe2").contentWindow.document.body.scrollHeight + "px"; }
  function AdjustIframeHeight(i) { document.getElementById("iframe2").style.height = parseInt(i) + "px"; }
  </code></pre>
  
  <p></p>
  
  <p>Not sure how to move on from there. I'd really appreciate some help.</p>
  
  <p>Thanks in advance!</p>
  
  <p><strong>EDIT:</strong> 
  The search works now (saw that I put the javascript above the html so I put it under it to get it working) so this is what I want to do with the search results:</p>
  
  <p>I intend to use the search box to enter a page number such that when the user clicks "Go" the search will look for that page and scroll the user down to where the result (that is, the page number) is.</p>
  
  <p><strong>EDIT 2:</strong>  I just thought I'd mention that my page numbers are written like this: -2- for page 2, -3- for page 3, etc.</p>