Search code examples
phpgoogle-custom-search

use iframe on google custom search


I'm making a site in php and I'm using google custon search for my site.for this I'm using this code

 <form action="http://192.168.0.113/boobloom/site/search.php" name="search"  id="cse- search-box" >
   <input type="hidden" name="cx" value="018095423333672301222:n5ebktimfxc" />
   <input type="hidden" name="cof" value="FORID:9" />
   <input type="hidden" name="ie" value="UTF-8" />
   <div class="txt-box"><input type="text" name="q"  /></div>
  <div class="boob-img">
  <input type="image" src="images/boob-img.jpg" name="sa" value="Submit"  /></div>
 </form>
 <script type="text/javascript" src="http://www.google.com/coop/cse/brand?form=cse-    search-box&lang=en"></script>

but now my requirement is show the result on new page with Iframe. I Never use Iframe before this. how can I do this?thanks in advance..

finally I took code from Google Custom Search Engine and put the result in a page.and its working correctely but the IFrame height is too much..

  <script type="text/javascript">
            var googleSearchIframeName = "cse-search-results";
            var googleSearchFormName = "cse-search-box";
            var googleSearchFrameWidth = 600;
            var googleSearchDomain = "www.google.com";
            var googleSearchPath = "/cse";
        </script>

   <script type="text/javascript" src="www.google.com/afsonline/show_afs_search.js"></script>

I try to change the FrameWidth variable to lower value but it still doesn't work..how can I do this?

var googleSearchFrameHeight = 300;


Solution

  • It's been a while since I worked with iFrames so this could be slightly wrong & need a bit of modification, but try this:

    <form action="http://www.google.com/search" target="iframe" method="get" onSubmit="Gsitesearch(this)">
         <input name="q" type="hidden" />
         <input name="qfront" type="text" /> 
      <input type="image" src="images/boob-img.jpg" value="Submit" />
    

    And then the iFrame could look something like this:

    <iframe name="iframe" src="" />
    

    Basically, give the iFrame a name value & have URLs or form actions target it.

    Hope this helped!