【问题标题】:How to load search result in an iframe and in a new page?如何在 iframe 和新页面中加载搜索结果?
【发布时间】:2011-09-08 04:49:42
【问题描述】:

好的,我在这些方面完全是菜鸟。但我需要在我网站的不同页面中使用 iframe 打开搜索结果。有人已经这样做了吗?

示例,当您点击 go 时,它将重定向到我网站的不同页面,并在 iframe 中搜索结果。

代码是这样的:

<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>

提前致谢!

【问题讨论】:

标签: search load


【解决方案1】:

就我个人而言,我会通过首先编写 iframe(没有 src)来简化此行为,然后将其隐藏,然后在发生操作时将源更改为您想要的任何内容,然后取消隐藏它。

请注意,出于竞争原因,Google 不允许在 iframe 中使用他们的结果。

【讨论】:

    猜你喜欢
    • 2016-07-13
    • 1970-01-01
    • 1970-01-01
    • 2014-05-15
    • 1970-01-01
    • 1970-01-01
    • 2022-01-18
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多