How can I add a Google search box to my website?

后端 未结 4 1566
无人共我
无人共我 2020-12-02 17:10

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 doe

4条回答
  •  情话喂你
    2020-12-02 18:04

    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.

提交回复
热议问题