Dutchbox
Dutchbox

Reputation: 3

How to load search result in an iframe and in a new page?

Okay, im a total noob at these..but I need to open the search result with the iframe in a different page of my site. Anyone have already done this?

sample, when you hit go it will redirect to different page of my site and the search results in an iframe.

code is something like this:

<html>
  <head>
    <title>Google Preview</title>
    <style>iframe { width: 800px; height: 600px }</style>
  </head>
  <body>
    <form method='get' action='http://www.google.com/search' target='results'>
      <label for='q'>Google Search:</label>
      <input name='q'/>
      <input type="submit" value="Go">
    </form>
    <script>
      try {
        document.write('<iframe name="results"></iframe>');
      } catch (e) {
        alert(e);
      }
    </script>
  </body>
</html>

Thanks in advance!

Upvotes: 0

Views: 1118

Answers (1)

Kzqai
Kzqai

Reputation: 23082

Personally, I would simplify this behavior by writing the iframe (with no src) first, and just hiding it, and then change the source to whatever you want when an action occurrs and then unhide it.

Note that google doesn't allow their results to be used in an iframe, for competitive reasons.

Upvotes: 1

Related Questions