首页 > 解决方案 > Opensearch - 更改搜索引擎的名称

问题描述

我一直在尝试将 opensearch 支持添加到我的网站。这就是我所拥有的 opensearch.xml 文件:

   <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <script/>
  <ShortName>Host</ShortName>
  <Description>Search my Website</Description>
  <InputEncoding>UTF-8</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">Favicon url</Image>
  <Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&amp;q={searchTerms}" />
  <Url type="text/html" method="GET" template="http://yoursite.com/?s={searchTerms}" />
  <SearchForm>http://yoursite.com/</SearchForm>
</OpenSearchDescription>

但它正在将 URL 名称注册为 Chrome 设置中的搜索引擎名称以及按标签建议。我可以更改什么来识别具有不同名称的搜索引擎?

标签: google-chromeopensearch

解决方案


首先,该脚本标签不应该在那里,所以你应该有这样的东西:

 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <ShortName>Host</ShortName>
  <Description>Search my Website</Description>
  <InputEncoding>UTF-8</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">Favicon url</Image>
  <Url type="application/x-suggestions+json" method="GET" template="http://suggestqueries.google.com/complete/search?output=firefox&amp;q={searchTerms}" />
  <Url type="text/html" method="GET" template="http://yoursite.com/?s={searchTerms}" />
  <SearchForm>http://yoursite.com/</SearchForm>
</OpenSearchDescription>

那么,您是否尝试过更改页面中包含的链接元素的名称?

<link rel="search" href="/opensearchdescription.xml" type="application/opensearchdescription+xml" title="name" />

推荐阅读