Search bar plugin for Mozilla Firefox
Posted on 03 January 2010 by Jason Grimme
In most Firefox layouts, there is a search bar in the upper-right corner that allows you to type in a term and use GET to make a search request.
At work we have a ticket system with ticket IDs and I frequently need to go to the home page, enter the ticket ID, and then click a button to view it. I thought it would be nice to change the usage of the search plugin so that I could enter the ticket ID and jump right to it. I had a few experiences I would like to share.
First, the search plugin is a basic XML file that follows Amazon’s OpenSearch standard. The structure is pretty basic.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | <?xml version="1.0" encoding="UTF-8"?> <!-- Ver 1.0 jGrimme Dec 16 09--> <OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/" xmlns:moz="http://www.mozilla.org/2006/browser/search/"> <ShortName>Ticket Jumper</ShortName> <Description>Jump to a Ticket</Description> <InputEncoding>UTF-8</InputEncoding> <Image width="16" height="16">data:image/x-icon;base64,AAABAAEAEBAQAA [ .. Shortened ..] CP//gBj////4////+P/</Image> <Url type="text/html" method="GET" template="http://www.example.com"> <Param name="QueryTermName" value="{searchTerms}"/> <Param name="AdditionalParameter" value="Additional_Value"/> </Url> <SearchForm>http://www.example.com</SearchForm> </OpenSearchDescription> |
You may chose to provide an image file that will be displayed next to the search bar, or you can base64 encode the PNG file so that you can distribute the search plugin in one file (This is the standard).
Save this as an XML file and you have two options. You can either copy it into your Mozilla directory (Windows ~= C:\Program Files\Mozilla Firefox\searchplugins\) or host it so that others may install it.
To do the second option, make a HTML file and place it in a public directory with the XML file.
In the HTML file, have a link that calls a Javascript function as follows:
1 2 3 4 5 6 | <script type="text/javascript"> function install() { window.external.AddSearchProvider(SearchPlugin.xml"); } </script> |
Tags | Firefox, OpenSearch, Search Plugin
