Scott Hanselman

Adding OpenSearch to your website and getting in the Browser's Search Box

July 21, 2008 Comment on this post [18] Posted in Musings | Tools | Web Services
Sponsored By

I was over at http://search.twitter.com earlier today and I noticed the Search Box in Firefox had a blue lit-up dealie:

image

Hm...OK. What's that? I hit another site and didn't see it. Weird. Ok, View-Source then, what drives you little blue thing?

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

Hey, that's not something I've seen before. What's in it...http://search.twitter.com/opensearch.xml...

<?xml version="1.0" encoding="UTF-8"?>
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Twitter Search</ShortName>
<Description>Realtime Twitter Search</Description>
<Url type="text/html" method="get" template="http://search.twitter.com/search?q={searchTerms}"/>
<Image width="16" height="16">http://search.twitter.com/favicon.png</Image>
<InputEncoding>UTF-8</InputEncoding>
<SearchForm>http://search.twitter.com/</SearchForm>
</OpenSearchDescription>

Ah! I totally get it. Excellent. I shall make my own immediately! I added this file to my website and added a <link> line as seen in the first example above that pointed to it.

<?xml version="1.0" encoding="UTF-8" ?> 
<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
<ShortName>Hanselman Search</ShortName>
<Description>Search Scott Hanselman's Blog</Description>
<Url type="text/html" method="get" template="http://www.hanselman.com/blog/...snip...q={searchTerms}"/>
<Image width="16" height="16">http://www.hanselman.com/blog/favicon.ico</Image>
<InputEncoding>UTF-8</InputEncoding>
<SearchForm>http://www.hanselman.com/</SearchForm>
</OpenSearchDescription>

Bam.

image

I wonder if it works in IE7?

image

Pow! I wonder if Live.com supports it?

  image

Eek! FAIL. I'll mention that to someone at Live.com

OpenSearch is a really easy feature that you can add to your website in literally minutes. Seconds if you type fast. Check me out noticing this only three years late. :)

Give it a try!

IMPORTANT NOTES: Make sure you include the first line of the XML file (the XML declaration) or IE will ignore it and nothing will happen when you add it. Also, make sure you include the default XML namespace or Firefox will give you an error: "Firefox could not download the search plugin"

Technorati Tags: ,

About Scott

Scott Hanselman is a former professor, former Chief Architect in finance, now speaker, consultant, father, diabetic, and Microsoft employee. He is a failed stand-up comic, a cornrower, and a book author.

facebook twitter subscribe
About   Newsletter
Hosting By
Hosted in an Azure App Service
July 21, 2008 13:09
Whoa, Hanselman Search just passed up HotBot and AltaVista in the search engine rankings. One of the best opensearch providers I've seen is SearchDotNet, by Dan Appleman: http://www.searchdotnet.com/articles/opensearch.aspx
July 21, 2008 13:47
This feature is one of the best hidden "secrets" of modern web browsers. I have several providers; such as search for a MSKB article, a hotfix, event-id etc.
I still tell people about the orange down-arrow in IE7, which appears next to the search field when it finds an OpenSearch provider, and they get amazed. It was only a few months I told some of your colleagues here in Sweden about that at a search seminar held at the Microsoft campus.
July 21, 2008 14:13
open search is awsome :)
and ie had it before firefox :O cant say that about many standards :)
aL
July 21, 2008 14:18
I think Live Search USED to support opensearch discovery, many many design iterations ago. It was that and IE7 that supported it first as I recall.

IMO its worth investigating the many other features of OpenSearch.
July 21, 2008 14:30
aL: IE7 and Firefox2 were released 6 days apart - so IE only just beat Firefox. Yet, Firefox's implementation has more features (not least the favicon).
July 21, 2008 15:39
Scott,

OpenSearch is great, and so easy to implement - I wrote a provider for our product in my lunch hour, handed it over to the dev guys (for real coding - error handling, an all that boring stuff.. ;-) and the PR we got was incredible. Also, integration with MS Search Server and SharePoint comes free!!

.. Ken
July 21, 2008 15:56
We run OpenSearch on our site www.brownbook.net, works really well in Firefox, but seems to have defaulted Atom stylee for IE, I will need to do a bit more digging... anyone know why?
July 21, 2008 16:26
How many people actually use Live Search? ;/
July 21, 2008 18:35
July 21, 2008 20:24
And don't forget: application/x-suggestions+json

http://developer.mozilla.org/en/docs/Creating_OpenSearch_plugins_for_Firefox

Which will give you that awesome auto-suggest you see with the "out-of-the-box" Google provider in FF.
July 21, 2008 21:24
I use it all the time. BlogEngine.NET have had it implemented since version 1.0 over a year ago. It's one of those things that gives a wow-effect when people discover it and it is so easy to implement as you also demonstrated above.
July 22, 2008 4:11
Yeah, it's a nice feature, but IE trumps FF in discoverability. IE's orange drop down is *way* more noticeable than that incredibly pale blue highlight in FF. What were they thinking? I had to look twice at the screenshot before I even saw what you were talking about...
July 22, 2008 11:45
Risking to sound like an Opera fanboi:

In Opera: right click on any search field.
Choose "Create search"
Optional: alter the description and/or give a shortcut name
Click Ok

Now I can go "S OpenSearch" in my address bar to search on scott hanselman's site and search for Opensearch.
Or use the search engine search box like other browsers have.
Or select a word in a webpage, rightclick and go "search with Scott Hanselman"

Although I like that there is a standard for it for developpers to give some way to customize it, I think it is a bit redundant seen previously mentioned technique has worked for years without any effort from the devoloper.

As always: this is my opinion, but I'm more then willing to change it
July 22, 2008 14:03
Awesome, going to implement this on my blog as well this evening. Thanks! :)
July 23, 2008 20:51
What's more interesting than setting up OpenSearch for internet-facing sites is adding your INTRANET search engine and make it the default! As far as I know, no one's really doing this, despite how easy it would be to implement. So there's a thought: use this for your intranet.
July 25, 2008 0:22
Note that you can add more than one open search in your site/blog. I did it in my blog (see for yourself).
July 26, 2008 16:32
For you Firefox fans you can use Add to Search Bar 1.7 Firefox Extension to add any search on any website to the search bar, even ones that do not have the code described in this article.

Make any pages' search functionality available in the Search Bar (or "search box")...
https://addons.mozilla.org/en-US/firefox/addon/3682
August 23, 2008 16:47
Hi I would like to mention another search engine for dot net developers which cover all good sites for dot net and related technologies as of August, 2008.

http://tips.developersvoice.com/devsearch

This developers search engine is inspired by searchdotnet.com and I try my best achieve even batter results. Both these developers search engines would greatly help the developer’s community.

DO test it yourself and let me know your comments.

Comments are closed.

Disclaimer: The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.