0

我想在我的网站上制作一个简单的搜索框。我认为就我的情况而言,最好的方法是使用 w3schools.com 之类的东西。当用户键入 smth 并按 Enter 时,它会重定向到 google.com/search,并且它将仅从 google 中的 w3schools.com 搜索,因为在 url 中给出了 site:www.w3schools.com。我怎样才能做到这一点?

4

4 回答 4

0

只需浏览源代码并获取所需的一切,在 HTML 操作指南的情况下通常会使用该技巧:

<form method="get" name="searchform" action="http://www.google.com/search" target="_blank">
    <input type="hidden" name="sitesearch" value="www.yoursite.com">
    <input type="text" name="as_q" size="20" value="Search yoursite.com">
    <input type="submit" value="Search" title="Search">
</form>
于 2012-07-22T21:48:29.457 回答
0

一个简单的解决方案是这样的:

<html>
<head></head>
<body>
<form method="get" name="searchform" action="http://www.google.com/search" target="_blank">
    <input type="hidden" name="sitesearch" value="stackoverflow.com">
    <input type="text" name="as_q" size="20" value="Search stackoverflow.com">
    <input type="submit" value="Search" title="Search">
</form>
</body>
</html>

但你也应该看看这个: http ://www.google.com/cse/

于 2012-07-22T21:48:55.233 回答
0

好。实际上,这似乎是一件很容易的工作。我在以下位置找到了解决方案: http ://www.askdavetaylor.com/how_can_i_add_a_google_search_box_to_my_web_site.html/

于 2012-07-22T21:49:24.083 回答
0

我认为您正在寻找的是Google Custom Search Engine。从这里开始:http://www.google.com/cse/docs/http://www.google.com/cse/manage/all

于 2012-07-22T21:53:13.570 回答