Adding Search providers to IE 7 using OpenSearch 1.1


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

Comments (36)

  1. Anonymous says:

    As useful as this all is, I (and I’m sure others will share this) have some concerns as to the window.external.AddSearchProvider(“URL”) functionality you’ve described. You should know by now that very few people actually read the multitude of dialogs that pop up at them during the course of their browsing. "’Are you sure you want to send this information?’ Of course I am, why else would I have clicked Submit?" Adding one more dialog for users to ignore, and, through that dialog, the potential for a malicious site to basically hijack an unknowing user’s searching experience.. this doesn’t seem like the best way to go about making a secure experience.

    I’ll leave it to the hordes of "standards" fanatics to whine about the further departure from strict and exclusive ECMAScript support.

  2. Anonymous says:

    Good. Glad to hear. Open Search is the way to go!

  3. Anonymous says:

    What about websites that search via POST requests. For example on my site http://www.teckreviews.com/ users submit their search terms via a POST request and then I filter out bad-words, words that are not too short etc, and if the result is successful I redirect them to a page of their search results.

    So my question is, does the OpenSearch support POST requests :)?

  4. Anonymous says:

    According to http://blogs.msdn.com/ie/archive/2005/09/14/466278.aspx, "it describes HTML output (via <Url type="text/html"/>), supports the POST verb and is a functional super-set of the ‘src’ format.". So it looks like it’ll support POST 🙂

  5. Anonymous says:

    What advantages does using open search give over the current method used by Mozilla and (I think) Opera? As there is an existing implementation, it would seem to make sense to be compatible with that, even if that is hard for Microsoft to do.

  6. Anonymous says:

    Do you show the URL of the search provider BEFORE it’s added?

    Do you check if it’s already been added?

    Do you ensure in any way that the site given for search is trusted (or at least not in Restricted Sites)?

    Do you check if it is a Phishing site?

    Do you check the protocol of the URL to ensure it’s not an exploit (javascript:, etc)?

    Do you load the icon for the search from the website, like favicons?

    If the preferred search is already in the list, do you let the site change the preferred search in the user’s box? e.g. if I’m at GMail site and add their GMail search URL, can they put something on their page so that the IE search box defaults to GMail search? And when I go to Yahoo.com the search box defaults to their search? This could be cool if there is more than one search box (one context sensitive, the other just my plain normal search).

    Can the search URL be context sensitive? e.g. Can I add a search such that when I am at MSDN the search box does google.com/search?q=site:msdn.com+%s

    Have I asked enough questions?

  7. Anonymous says:

    The Add Search Provider dialog will only prompt as a result of an explicit user action.

    We modelled it after the AddFavorite API for exactly the reasons that PartiotB and Charlie described above.

  8. Anonymous says:

    So, "window.external.AddSearchProvider(‘URL’)"

    I pressume, that this WILL REQUIRE a user action, in order to be called?

    E.g. I better not be able to do this:

    <head>

    <script>

    window.external.AddSearchProvider(‘www.AdultContentSiteUserNeverVisited’);

    </script>

    </head>

  9. PatriotB says:

    wafn: Malicious sites shouldn’t be able to hijack that dialog box. For example, prior to XP SP2, there were many sites that used window.external.addfavorite (or whatever it’s called) to pop up the Add Favorite box. But with SP2 it only will work when it is a result of a user action (e.g. click). I would expect this new method to work the same way.

    Aaron – is window.external.AddSearchProvider documentation up on MSDN anywhere?

  10. Anonymous says:

    Ineresting post on the Amazon Web Services Blog:Microsoft’s IE blog is reporting on the behind the scenes efforts which lead up to the recent announcement that IE7 will support A9.com’s OpenSearch interface. You can read even more about this on the A9 blog. [Amazon Web Services Blog: Behind the Scenes at Microsoft, A9, and Amazon]And the IE Blog’s view of why this is important: It’s been a lot of fun working with A9. But, this is just the beginning. The OpenSearch spec occupies a special place because it intersects 3 important communities – browser, search and RSS. We want to hear from all of you. My dream is that OpenSearch is adopted by all the browsers and millions of sites (Internet and Intranets) and that a significant percentage of these sites also expose RSS. [IEBlog : IE7 and OpenSearch: Behind the scenes]…

  11. Anonymous says:

    to Ian Thomos:

    The search plugins used by Mozilla/Firefox/etc (see http://mycroft.mozdev.com ) are based on the format used by Apple’s Sherlock. Mozilla did the best thing at the time, using an existing ‘standard’ (see http://mycroft.mozdev.org/deepdocs/quickstart.html#standard )

    Now, however, there’s a new format OpenSearch, which is truly open (the 1.1 draft has a Creative Commons license), and it’s also in XML, which is much more in-tune with Mozilla’s practices than the existing plugins.

    I’m quite familiar with both specifications, and I really think OpenSearch is substantially better. It isn’t complicated, makes use of the existing standards of RSS/Atom, has virtually all the features of the ‘src’ search plugins and more, and is fully extensible.

    It should be a relatively easy operation to convert an existing ‘src’ plugin into an OpenSearch Description document. Which, by the way, can use the <link /> tag in HTML to provide auto-discovery, which is very cool, just like RSS/Atom has today.

  12. Anonymous says:

    As reported by the Amazon Web Services Blog and the IEBlog there have been some behind the scenes efforts between the Microsoft IE7 development team and their colleagues at Amazon’s A9 to roll Opensearch capability into the next IE release….

  13. Anonymous says:

    if you want to add search engines in a similar way to adding them to firefox you can use my AddToSearchBar tool http://www.fieryidris.co.uk/downloads

    this will add almost any search engine to the drop down list in IE7. i say almost any because it works on the search result URL and not every search page gives a search-specific URL.

  14. Anonymous says:

    HAS ANYONE NOTICED….

    that C# cannot be searched for on craigslist.org? That sucks big time for Microsoft!!

  15. Anonymous says:

    It is snowing outside, I have a cup of coffee playing with new IE7! I have installed yesterday. It has…

  16. Anonymous says:

    For those of you interested in more information on how IE7 takes advantage of OpenSearch check out the…

  17. Anonymous says:

    For those of you interested in more information on how IE7 takes advantage of OpenSearch check out the…

  18. Anonymous says:

    For those of you interested in more information on how IE7 takes advantage of OpenSearch check out the…

  19. Anonymous says:

    Several parties have made claims about how search works in IE7. I think those

    claims are awfully confusing,…

  20. Anonymous says:

    I’m loving the work many of my former teammates are doing over on IE7.

    Keyboard (or mouse)&amp;nbsp;shortcut’s…

  21. Anonymous says:

    &lt;p&gt;I’ve recently had to look up a few APIs at &lt;a href=&quot;http://www.pinvoke.net/&quot; class=&quot;ExternalLink&quot;&gt;http://www.pinvoke.net/&lt;/a&gt; so I thought I’d whip up an &lt;a href=&quot;http://en.wikipedia.org/wiki/OpenSearch&quot;

  22. Anonymous says:

    O možnosti přidání vlastního vyhledávání do Internet Exploreru 7 psal už dávno Michal Altair Valášek

  23. Anonymous says:

    [2 blogs ago (back on what is now windows-now.com), I blogged about the IE7 Search Bar + Open Search