Web Development

How do I... Add TechRepublic as a search provider in my Web browser?


The download version of this blog entry contains the sample XML and JavaScript required to complete this project.

In this How do I... tutorial we are going to add TechRepublic as a search provider in both Internet Explorer 7 and Firefox 2. First, we need to create the base XML, which contains the configuration for the search provider. This XML file is in the OpenSearch format, and the sample configuration file we are using contains the elements shown in Table A.

Table A

XML Attribute

XML Attribute Value

ShortName This is the name that appears on the list of Search Providers.
Description This is a longer description of the Search Provider.
URL This is the URL that will be called including the provided search term.
Image This is the small image that will appear in the Search Providers drop-down in browsers, such as Firefox, that support them.
Developer This is the name of the developer(s) who developed the configuration file.
Contact This is the e-mail address of the named developer(s)

An example of the XML file is shown in Listing A.

Listing A

<?xml version="1.0" encoding="UTF-8"?>

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">

<ShortName>Web Search</ShortName>

<Description>Example.Com Search Engine</Description>

<Url type="text/html" template="http://example.com/?q={searchTerms}"/>

<Image width="16" height="16">http://example.com/example.png</Image>

<Developer>Example.Com Developers</Developer>

<Contact>developers@example.com</Contact>

</OpenSearchDescription>

In the case of TechRepublic, the search URL, including search terms and searching for search engines, looks something like the following:

http://www.techrepublic.com/search/index.php?q=search+engines&c=1

All we need to do is replace the appearance of the keywords in the sample URL with the replacement variable {searchTerms}. When you execute a search via the search widget, the terms you have entered into the text box are put into the URL in place of this variable. Thus, our complete sample URL would look like the following:

http://www.techrepublic.com/search/index.php?q={searchTerms}&c=1

Adding to the search provider

Now that we have our search URL, we can populate the template XML file shown above with all the details we need to add TechRepublic as a new search provider. As with all XML files, don't forget to ensure that all the special characters, such as the "&" are escaped. Our final XML file will look like Listing B.

Listing B

<?xml version="1.0" encoding="UTF-8"?>

<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">

<ShortName>Search TechRepublic</ShortName>

<Description>TechRepublic Search Engine</Description>

<Url type="text/html" template="http://www.techrepublic.com/search/index.php?q={searchTerms}&c=1"/>

<Image width="16" height="16">http://www.techrepublic.com/images/favicon.ico</Image>

<Developer>Greg Griffiths</Developer>

<Contact>greg.griffiths@greggriffiths.org</Contact>

</OpenSearchDescription>
Now that we have created the XML configuration file, we need to have some method of presenting this to the user so that they can click on a link and have the search provider added to their list. We do this by using the JavaScript method window.external.AddSearchProvider('<URL>'), which is defined on MSDN (Microsoft Developer Network) and is supported by both Internet Explorer and Firefox. We put this function into a sample page, the source of which is shown Listing C.

Listing C

<html>

<head>

<title>Add Search Engine</title>

</head>

<body>

<a href="javascript:window.external.AddSearchProvider('http://localhost/addengine/tr.xml');">add the engine</a>

</body>

</html>
Note: You will likely need to change the URL path to the tr.xml file to match your environment. While this code will allow you to add a search provider to either IE7 or Firefox 2, the appearance of the engines within the browser is slightly different. Firefox shows the search providers in a similar way to a Web page's FavIcon. Figure A and Figure B show how IE and Firefox present our new search engine to the end user.

Figure A

Internet Explorer 7

Figure B

Firefox 2
30 comments
Aaron A Baker
Aaron A Baker

How do I "Remove unwanted Search Engines such as the ever famous or rather infamous Google "depending on your perspective", Yahoo and a few other eavesdroppers I'd like to see gone?" At least from my browser. Any Ideas? Thanking you in advance. Regards Aaron

david.robles
david.robles

Uh, so how do I do it? How do I add techrepublic as a search provider?

technochic64
technochic64

http://search.techrepublic.com.com/index.php?q=TEST Go to the search drop down window and choose "Find more providers" On the right-hand side of the page under "create your own" add the above URL and add the name Tech Republic to the name field. Then choose install and click add provider when prompted. Very simple

Nik de Greek
Nik de Greek

Had a go at coding, easy enough instructions. Now I am really cooking with TR.

dlandis
dlandis

This is crazy but.. When I try using the addtr.html downloaded from this artical I get a link saying "add the engine" and when I click it the message at the bottom of IE7 says "Error on page" I try the "Find More Providers..." using the create your own and I get a popup in IE7 saying "Unable to add search provider. Create Your Own tool requires Internet Explorer 7" So none of this works for me. Any suggestions?

GDF
GDF

It's annoying that the listing text doesn't wrap - all the longer lines are hidden by the right-side advertisement column.

michael
michael

Cool! Interesting, quick, exercise. Had to change the '&' in line 5 to & and then it worked fine. Thanks!

fdoyle
fdoyle

if you want to see the largest "How-To" library in the world go to www.Level0Help.com. These are all flash tutorials on desktop products. Let me know who to contact and we can do a reseller deal. fdoyle@pchowto.com

D. Harold Stein
D. Harold Stein

In IE7 it is much easier to select "Find More Providers" from the drop-down menu on the search toolbar and follow the simple instructions. This can be easily accomplished in less than 60 seconds.

randy.wiseman
randy.wiseman

There is a firefox extension that'll do this. Called "Add To Search Bar"

Mark W. Kaelin
Mark W. Kaelin

In the interest of making life easier, you can reach the XML shown in the blog post here: http://i.t.com.com/i/tr/downloads/home/tr.xml Just change the location in the add.html file to read this location. Run the add.html file and now you can search TechRepublic from IE7 or Firefox no matter where you are on the Web.

svenlaier
svenlaier

I had the same problem. The error I made was trying to test with a link formed like this: file:///H:\tr.htm. Firefox (and IE7, I believe) only supports http, https and ftp protocols (and consequently not file) for the OpenSearch-spec. I hope this helps!

Mark W. Kaelin
Mark W. Kaelin

That is strange. IE7 is telling you you need IE7 to add a search provider. Is IE7 up to date? Do you have JavaScript turned off perhaps? Anyone have a suggestion?

Mark W. Kaelin
Mark W. Kaelin

I have an outstanding bug filed on this for a few weeks now. I understand your frustration. I'm going to use your complaint to further my cause. Thanks.

thisisside5
thisisside5

Disappointing that a How-To for Firefox won't display properly using that browser. Try loading it in IE Tab

lonewolftech
lonewolftech

Why would I want to add a search provider? If I want Google, that is my home page. If I want Ask or any other I just have them as bookmarks. What am I missing.

Greg Griffiths
Greg Griffiths

Randy, Thanks for the information, the extension looks good, but I think it may be doing the same thing underneath. The code in the article will also work cross browser which for many people is a requirement even for extranet/intranet sites let alone the web.

ttlanhil
ttlanhil

Some Konqueror users probably know this already, but in case it helps more people... This is with Konqueror/KDE 3.5.8 . 4.x may be different. Go to Settings->Configure Konqueror (you can also use the control centre). Select "Web Shortcuts". If the site isn't listed yet (and many already are), then select New. The name is what the users sees it as, so that can be anything. The URI is copied from a search page, just replace the search term with \{@}, and the shortcuts can be any short term you like. You can then use the shortcut as if it were a protocol, eg you could enter "wp:wikipedia" in your address bar, and you would get wikipedia's search for the term 'wikipedia'. All entries in the list work this way, the checkbox is whether to show the search provider in a popup... select a word (or phrase, or...) on a webpage, right-click, and you can have a list of search providers. I've found this functionality to be very useful for searching wikis for some games that I play, and in my research at university (select a word, easy search in citeseer, or wikipedia, or a dictionary? saves a lot of time)

benn_bh
benn_bh

If I tray to Install Hpleserjet 2600n printer to my laptop which has Window Vista and gives massage(spooler system is close restarting the spooler system. Please can you help me!

dlandis
dlandis

Found this regedit which cleared up my issue with IE7 telling me I need IE7 to add search provider: http://www.winhelponline.com/articles/122/1/ Fixed the "Find More Providers" option perfectly. I don't know if the XML config file method works but I image it would now.

cricket4b
cricket4b

Having a search bar open allows you to search without going to either your home page or opening a search page. It just eliminates a step. If you have more than one tab open you can search from the unwanted tab without closing ones you want to keep open. This is especially good when you are troubleshooting or comparing something.

s.butera
s.butera

Thanks...That just made it incredibly easier to add TechRepublic as a search engine

Greg Griffiths
Greg Griffiths

The main usage of this for me when I developed it was to allow my companies custom Intranet apps with build in search engines to be available in the search bar to our users, so they did not have to be in the application to issue a search. By extentsion, the same principal works for other search engines, which may not be available as a default Add On, or for developers who need to give their end users a single click button to add the engine rather than a guide to follow.

lonewolftech
lonewolftech

Thanks for the answer. I just have the other often used sources on the toolbar and additonal resources in a folder in bookmarks. It works great for me and I often have a number of tabs open at the same time.

Lil ndn
Lil ndn

That definitely did the trick...EZ, thanks again!

Editor's Picks