如何在 iframe 和新页面中加载搜索结果?
好吧,我对这些完全是菜鸟..但我需要在我网站的不同页面中使用 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>
提前致谢!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
就个人而言,我会通过首先编写 iframe(没有 src)并隐藏它来简化此行为,然后在发生操作时将源更改为您想要的任何内容,然后取消隐藏它。
请注意,出于竞争原因,Google 不允许在 iframe 中使用其结果。
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.