如何将Google搜索框添加到我的网站? [英] How can I add a Google search box to my website?

查看:117
本文介绍了如何将Google搜索框添加到我的网站?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将Google搜索框添加到我自己的网站上。我希望它能搜索Google本身,而不是我的网站。

 < form method =getaction = https://www.google.com/search\"> 
< input type =textname =gsize =31value =>
< / form>

当我尝试进行搜索时,它会直接进入Google主页。嗯,实际上这是指向这里: https://www.google.com/webhp



有没有人有不同的解决方案?我在做什么错了?

解决方案

不好意思回复一个较旧的问题,但我想澄清最后一个问题。 / p>

对表单使用get方法。
当您的输入字段名称为g时,它会生成如下所示的URL:

  https ://www.google.com/search? g = [来自输入字段的值] 

但是当您使用Google进行搜索时,您会注意到以下网址:

  https://www.google.nl/search?q=谷歌+搜索+栏

Google使用qQuerystring变量作为搜索查询。
因此,将您的字段从g重命名为q可以解决问题。


I am trying to add a Google search box to my own website. I would like it to search Google itself, not my site. There was some code I had that use to work, but no longer does:

<form method="get" action="https://www.google.com/search">
<input type="text" name="g" size="31" value="">
</form>

When I try making a search, it just directs to the Google homepage. Well, actually it directs here: https://www.google.com/webhp

Does anyone have a different solution? What am I doing wrong?

解决方案

Sorry for replying on an older question, but I would like to clarify the last question.

You use a "get" method for your form. When the name of your input-field is "g", it will make a URL like this:

https://www.google.com/search?g=[value from input-field]

But when you search with google, you notice the following URL:

https://www.google.nl/search?q=google+search+bar

Google uses the "q" Querystring variable as it's search-query. Therefor, renaming your field from "g" to "q" solved the problem.

这篇关于如何将Google搜索框添加到我的网站?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆