google-chromesearchomnibox

chrome omnibox how to add the search on domain


How one configure his web site to let users search only on his domain using omnibox?

Example:

I didn't find anyhing in the source code.


Solution

  • Yes it's possible. I did this for my blog.

     <link rel="search" type="application/opensearchdescription+xml" title="The Sheng Blog" href="/resources/opensearch.php"/>
    

    opensearch.php looks likes this:

     <?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>
    

    I learned this from http://www.opensearch.org/Specifications/OpenSearch/1.1. The autocomplete part is optional. Return it in JSON format.

    For example, if you search "a", return ["a","about","across","all","and"]. (Notice I put your query in the array as item 0.)

    My autocomplete only seems to work in Firefox. This might be something with my sub domain. I also couldn't get it to work in IE or Chrome.