0

Today I accidentally discovered a feature in Google Chrome, and it's made me curious.

Say I'm typing in the Google Chrome search bar:

Step 1

After having typed "stack", the first suggestion is "stackoverflow.com". If I then press the Tab key, this happens:

Step 2

Note the "Search Stack Overflow:" box that has appeared. Subsequently typing a query and then pressing Enter results in only "stackoverflow.com" being searched.

How does this work? Is there some web standard for making a website searchable?

If I try the same thing with Wikipedia, it doesn't work, so I don't think this is something being done on the Google Chrome client-side. There must be something server-side involved. Also, I'm aware that popular search engines will search inside websites "by default" anyway. I'm just curious about how this particular feature works.

Timothy Shields
  • 75,459
  • 18
  • 120
  • 173
  • possible duplicate of [How to add google chrome omnibox-search support for your site?](http://stackoverflow.com/questions/7630144/how-to-add-google-chrome-omnibox-search-support-for-your-site) – Rob W Jul 03 '13 at 18:07

1 Answers1

0

Stack Overflow appears to implement the OpenSearch Specification, while Wikipedia does not. If you look in the source, you'll see a line:

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

The opensearch.xml file contains

<?xml version="1.0" encoding="UTF-8" ?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/">
  <ShortName>Stack Overflow</ShortName>
  <Description>Search Stack Overflow: Q&amp;A for professional and enthusiast programmers</Description>
  <InputEncoding>UTF-8</InputEncoding>
  <Image width="16" height="16" type="image/x-icon">https://sstatic.net/stackoverflow/img/favicon.ico</Image>
  <Url type="text/html" method="get" template="http://stackoverflow.com/search?q={searchTerms}"></Url>
</OpenSearchDescription>

Chrome supports this as well, and lets you search the site in the method you saw.

jprofitt
  • 10,874
  • 4
  • 36
  • 46