【问题标题】:Custom Google Search redirects to https://cse.google.com/cse/all自定义 Google 搜索重定向到 https://cse.google.com/cse/all
【发布时间】:2018-07-26 20:49:56
【问题描述】:

您好,我正在对我的网站使用自定义谷歌搜索,但是当我搜索它时,它只会重定向到 https://cse.google.com/cse/all。我将生成的公共 URL 插入到表单标签的操作部分。在浏览器上复制和粘贴 URL 时,搜索确实有效。谢谢!

这是我的 HTML 代码:

<form method = "get" title = "Search Form" action="https://cse.google.com/cse?cx=001331330360923127228:ghn4eoirwti">
  <div>
    <input type="text" id="q" name="q" value="Search" title="Search this site" alt="Search Text" maxlength="256"/>
    <input type="image" id="searchSubmit" name="submit" src="http://webresource.its.calpoly.edu/cpwebtemplate/5.0.0/common/images_html/header/search-arrow.png" alt="Go" title="Submit Search Query" />
  </div>
</form>

【问题讨论】:

    标签: google-search google-custom-search


    【解决方案1】:

    您正在尝试在操作 URL 中传递参数 (cx);因此返回缺少您的 cx 参数并移至传递的新参数(q)。下面的代码将您的 cx 值放在一个隐藏字段中,以便与 q 参数一起传递;试试这个:

    <form method = "get" title = "Search Form" action="https://cse.google.com/cse/publicurl">
      <div>
        <input type="text" id="q" name="q" value="Search" title="Search this site" alt="Search Text" maxlength="256"/>
        <input type="hidden" id="cx" name="cx" value="001331330360923127228:ghn4eoirwti">
        <input type="image" id="searchSubmit" name="submit" src="http://webresource.its.calpoly.edu/cpwebtemplate/5.0.0/common/images_html/header/search-arrow.png" alt="Go" title="Submit Search Query" />
      </div>
    </form>
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-05-16
      • 2018-12-14
      • 1970-01-01
      相关资源
      最近更新 更多