【发布时间】:2011-03-18 11:35:30
【问题描述】:
我的网站上有一个 Google 自定义搜索引擎,并且我最近实现了 opensearch XML 文件,这样我就可以在浏览器的搜索框中添加我们网站的搜索。
知道如何将自动完成/建议功能添加到浏览器的搜索框中吗?
【问题讨论】:
我的网站上有一个 Google 自定义搜索引擎,并且我最近实现了 opensearch XML 文件,这样我就可以在浏览器的搜索框中添加我们网站的搜索。
知道如何将自动完成/建议功能添加到浏览器的搜索框中吗?
【问题讨论】:
我假设您已经在您的 Google CSE 搜索引擎配置中启用了“自动完成”。
下一步是在OpenSearchDescription 元素中添加带有type“application/x-suggestions+json”的Url 元素。我对此进行了一些研究,以下 URL 似乎应该可以工作(请务必输入您自己的合作伙伴 ID,其中显示 [YOUR PARTNER ID]:
http://www.google.com/complete/search?q={searchTerms}&partnerid=`[YOUR PARTNER ID]`&ds=cse&output=firefox
例如,
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
...
<Url type="application/x-suggestions+json" method="get" template="http://www.google.com/complete/search?q={searchTerms}&partnerid=#YOURPARTNERID#&ds=cse&output=firefox"></Url>
</OpenSearchDescription>
这是我创建的a little webapp(预先填充了一些有用的值)来帮助您处理 OSDD。
【讨论】: