检测并向用户提供将OpenSearch插件添加到浏览器的功能

时间:2018-11-03 10:32:32

标签: javascript opensearch

我遵循this tutorial,并使用下面的代码使我的网站可直接从浏览器的地址栏中进行搜索,因此用户可以轻松地将其用作我的网站内容的搜索引擎。

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/"
                       xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <ShortName>[SNK]</ShortName>
  <Description>[Search engine full name and summary]</Description>
  <InputEncoding>[UTF-8]</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">[https://example.com/favicon.ico]</Image>
  <Url type="text/html" template="[searchURL]">
    <Param name="[key name]" value="{searchTerms}"/>
    <!-- other Params if you need them… -->
    <Param name="[other key name]" value="[parameter value]"/>
  </Url>
  <Url type="application/x-suggestions+json" template="[suggestionURL]"/>
  <moz:SearchForm>[https://example.com/search]</moz:SearchForm>
</OpenSearchDescription>

我想检测用户是否已经将我的网站添加到浏览器搜索引擎列表中以停止向他提供该信息,我找不到是否可以使用JavaScript或其他方法检测到该信息。

0 个答案:

没有答案