嗨,我正在使用自定义Google搜索来搜索我的网站,但是当我搜索它时,它只会重定向到https://cse.google.com/cse/all。我将生成的公共URL插入到form标签的action部分。在浏览器上复制和粘贴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>
答案 0 :(得分:1)
您正在尝试在操作网址中传递参数(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>