Adding Search providers to IE 7 using OpenSearch 1.1

IEBlog

Internet Explorer Team Blog

Adding Search providers to IE 7 using OpenSearch 1.1

  • Comments 37

It’s our goal to make it easy for IE7 users to personalize their list of search providers.  The user should be able to target their search directly to site of their choice: MSDN, Intranet portal, Team Sharepoint, PubMed, NYTimes, Costco, USPS, Amazon, WikiPedia, Ebay, Craigslist, etc.  My last blog post mentioned we will be adding extensibility for Internet Explorer’s new Search Box in Beta 2.  We’re announcing the API at PDC during Chris Wilson’s talk on IE7.  Here are the details. 

The scenario has two steps:

  1. Users can easily add sites to their list of search providers
  2. Sites describe how IE can interface with them

The user experience for adding a search provider will be very similar to how adding a favorite works today.  Basically all the site needs to do is implement a window.external.AddSearchProvider(“URL”) call in their webpage which will prompt the end user.  When accepted, the search provider will appear in the Search Box dropdown list in IE.  The prompt will also ask if they would like to make this provider the default provider at the same time. 

The URL in this call will be a link to the OpenSearch 1.1 description document for your search query.  Below is an example of a description document for searching on MSDN:

<?xml version=”1.0” encoding=”UTF-8”?>
<OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearchdescription/1.1/”>
            <ShortName>MSDN</ShortName>
            <Description>MSDN Example Search</Description>
            <Tags>MSDN Developer</Tags>
            <Contact>admin@msdn.com</Contact> 

            <Url type="text/html" 
                   template="http://search.microsoft.com/search/results.aspx?qu={searchTerms}&amp;View={language?}&amp;p={startPage?}"/>

</OpenSearchDescription>

In this example when a user searches for “stuff” IE will navigate to: http://search.microsoft.com/search/results.aspx?qu=stuff&View=en-US&p=1.  The cool thing about OpenSearch is that the publisher has a choice of returning RSS or HTML or both.  Here’s an example of a site returning RSS as well as HTML:

<?xml version=”1.0” encoding=”UTF-8”?>
<OpenSearchDescription xmlns=”http://a9.com/-/spec/opensearchdescription/1.1/”>
            <ShortName>MSN</ShortName>
            <Description>MSN Example Search</Description>
            <Tags>MSN Web</Tags>
            <Contact>admin@msn.com</Contact> 

            <Url type=”text/html”
                   template=”http://search.msn.com/results.aspx?q={searchTerms}”/>  

            <Url type="application/rss+xml"
                   template=”http://search.msn.com/results.aspx?q={searchTerms}&amp;format=rss”/> 

</OpenSearchDescription>

How does IE pick which one to use?  IE will choose the first URL specified in the description doc.  In the example above, IE will use the HTML URL since it appears first.  This way, the site has the power to determine how they want the results to appear.  

For more details on creating providers using OpenSearch 1.1 please refer to the OpenSearch Description Document 1.1 Draft.  This format is licensed under creative commons and A9 owns the spec. 

Amar will post soon on how we worked with A9/Amazon to add HTML support to OpenSearch 1.1.

Until next time, keep browsing and have fun!

 - Aaron

  • Loading...