//Create a Custom Firefox Search Tool in Five Minutes

Create a Custom Firefox Search Tool in Five Minutes

site:yourblogname.com searchterm

This is an example how to search your blog as a query in Google. But have you ever wanted to learn how to make your own ‘Search Tools’ for Firefox so that you can look-up information on your own blog quickly, from anywhere on the internet? Or do you want to hack Google Custom search to improve your earnings and it’s functionality?

It turns out making a search tool is relatively simple. In fact using this tool, you can make one in about five minutes. The trick is to figure out what a search query on your blog looks like. For WordPress users, it might look like this:

http://yourblog.com/blog/?s=news&search=Search

This is important because you’ll notice the form asks you for a front of search term and a back of search term. The query itself should be left out so that your users can enter whatever they want. Let’s dissect the search query….

FRONT
http://yourblog.com/blog/?s=

QUERY
news

BACK
&search=Search

Your own search queries may look a bit different than this depending upon the software you use. To get the query preform a search using the GUI and then copy and paste the query from the navigation bar.

If you’re using Google custom search, you’ll notice that the query looks very different. This is because they use identifiers to keep track of revenues earned from custom search. Now, I have no idea if hacking their custom code is a violation of TOS but I’ve done it, it works but since it’s questionable I can’t flat out explain what to do here. Instead, we’ll create one using the WordPress specific query….

Ready.to then creates the XML file needed to add custom search to your top navigation bar. You can see where it puts the tool below:

Notice that I now have custom search option added to my Firefox Toolbar. That’s great, you’ve got an XML file, however if you upload the file to your blog and link to it, Firefox won’t know to execute the script. To do that you need to add a bit of javascript code to the header of your site and use another custom query for linking.

<script type="text/javascript">
<!--
function addp(csurl) {
try {
window.external.AddSearchProvider(csurl);
} catch (e) {
alert("You need to use Internet Explorer (7.0 or later)
or Firefox (2.0 or later) to install the OpenSearch plug-in.");
}}
//-->
</SCRIPT>

That script tells the browser what to do with the .xml file. Now we need to tell Firefox where to find it, and that it’s an executable and not just a linked file. We do this with the addp request defined in the header script…


<a href="#" onClick="addp("http://developertutorials.com/blog/DevTut.xml");">

This tells the browser that the file is executable, the script tells FireFox what to do with that executable (add it to the toolbar).

That’s it, if everything went well you’ve created a custom search tool for Firefox in about five minutes. You can get the Developer Tutorial Firefox Search Tool here.

2008-07-13T08:47:16+00:00 July 13th, 2008|Articles|0 Comments

About the Author:

Leave A Comment