chrome omnibox如何在域上添加搜索

Jon*_* M. 6 search google-chrome omnibox

如何配置他的网站让用户只使用omnibox搜索他的域名?

例:

  • 输入youtube.com然后按Tab键 在此输入图像描述
  • 或者输入yahoo.com然后按 在此输入图像描述
  • 尝试使用vimeo是行不通的

我没有在源代码中发现任何问题.

She*_*gar 2

是的,这是可能的。我为我的博客做了这个。

 <link rel="search" type="application/opensearchdescription+xml" title="The Sheng Blog" href="/resources/opensearch.php"/>
Run Code Online (Sandbox Code Playgroud)

opensearch.php 看起来像这样:

 <?xml version="1.0"?>
 <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
     <ShortName>The Sheng Blog (Beta)</ShortName>
     <Description>The Sheng Blog Search</Description>
     <Developer>Sheng Slogar</Developer>
     <LongName>Search the entire Sheng Blog</LongName>
     <InputEncoding>UTF-8</InputEncoding>
     <OutputEncoding>UTF-8</OutputEncoding>
     <Query role="example" searchTerms="code"/>
     <SyndicationRight>open</SyndicationRight>
     <AdultContent>false</AdultContent>
     <Language>en-us</Language>
     <Contact>contact@theshengblogg.comule.com</Contact>
     <Tags>code posts tutorials ideas playground</Tags>
     <Image width="16" height="16" type="image/x-icon">data:/ico;base64,AAABA...(Icon in base64)</Image>
     <Url type="text/html" template="http://theshengblogg.comule.com/search.php?s={searchTerms}"></Url>
     <Url type="application/x-suggestions+json" method="GET" template="http://theshengblogg.comule.com/autocomplete.php?search={searchTerms}&amp;json=true"/>
 </OpenSearchDescription>
Run Code Online (Sandbox Code Playgroud)

我从http://www.opensearch.org/Specifications/OpenSearch/1.1了解到这一点。自动完成部分是可选的。以 JSON 格式返回。

例如,如果搜索“a”,则返回 [“a”,“about”,“across”,“all”,“and”]。(请注意,我将您的查询作为第 0 项放入数组中。)

我的自动完成功能似乎只能在 Firefox 中使用。这可能与我的子域有关。我也无法让它在 IE 或 Chrome 中工作。