indiWiz.com

Subhash's Tech Log

OpenSearch search providers and browsers

with one comment

All the major browser vendors support the OpenSearch format (yes, this means including Microsoft IE8) for registering a search provider in your browser.

Writing a OpenSearch provider

Recently I wrote a search provider for my favorite book-buying site, Pustak.co.in:

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
	<ShortName>Pustak.co.in</ShortName>
	<Description>Pustak.co.in provider</Description>
	<InputEncoding>UTF-8</InputEncoding>
	<Url type="text/html"
		template="http://pustak.co.in/pustak/books/search?q={searchTerms}&amp;type=book&amp;page=1"/>
</OpenSearchDescription>

Hosting your search provider

To let people use your search provider, you need to host it in the web. For our example, let us assume that you host it here: http://yourhost/your_opensearch.xml.

The MIME type of this document can be left to its default application/xml, or can be made OpenSearch specific: application/opensearchdescription+xml.

Using JavaScript to register a provider

After deploying the OpenSearch XML in your host, we need to write a JavaScript function to register the provider with your browser:

<script type="text/javascript">
function registerYourSearchProvider(){
  window.external.AddSearchProvider("http://yourhost/your_opensearch.xml");
}
</script>

This JavaScript worked with Firefox, IE8 and Google Chrome. Opera 10 was not able to understand it.

Auto-discovering OpenSearch providers

Recently when I saw my Google Chrome search providers, I saw this list:

Chrome Search Providers

I was surprised to see this list because there are providers that I have not added specifically. How was Google Chrome “discovering” these providers?

A look into the HTML source of one of the auto-registering search provider, I found the following info (in the <head> section):

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

To let browsers auto-discover you as a search-provider, add the above in your sites!

Written by Subhash Chandran

November 25th, 2009 at 10:36 am

Posted in Uncategorized

Tagged with , ,

One Response to 'OpenSearch search providers and browsers'

Subscribe to comments with RSS or TrackBack to 'OpenSearch search providers and browsers'.

  1. Hi Subash,

    Interesting article.

    thanks,
    senthil

    senthilk

    4 Dec 09 at 3:51 pm

Leave a Reply