O'Reilly Hacks
oreilly.comO'Reilly NetworkSafari BookshelfConferences Sign In/My Account | View Cart   
Book List Learning Lab PDFs O'Reilly Gear Newsletters Press Room Jobs  


 
Buy the book!
Yahoo! Hacks
By Paul Bausch
October 2005
More Info

HACK
#13
Customize the Firefox Quick Search Box
Though Yahoo! Web Search is a default option in the Firefox search box, with some quick coding you can add many other Yahoo! Search types
The Code
[Discuss (0) | Link to this hack]

The Code

Maybe you're a fan of the Yahoo! Image Search (http://images.yahoo.com) and you'd like to be able to search for images quickly from Firefox. The first step in creating a custom entry is to perform a search and take a look at the URL. For this example, browse to http://images.yahoo.com, type Shakespeare into the search form, and click Search Images. You should receive a page full of various pictures of Shakespeare, but take a look at the URL in the address bar. The relevant pieces of the URL include the images.search.yahoo.com domain, the images file, and the p variable, which is set to the search query:

	http://images.search.yahoo.com/search/images?p=shakespeare

Now that you know how Yahoo! Image Search URLs are constructed, you can write the file that will tell Firefox where to send search requests. Create a file called yahoo_image.src in a plain-text editor such as Notepad, and add the following code:

	# Yahoo! Image Search
	#
	# Created April 16, 2005

	<SEARCH
		version="7.1"
		name="Yahoo! Image Search"
		description="Search for images at Yahoo!"
		method="GET"
		action="http://images.search.yahoo.com/search/images" >

	<input name="p" user>

	</search> 

As you can see, this quick file begins with an opening <SEARCH>tag that holds the name of the search, and a brief description. Everything before the question mark in the search results URL becomes the value of the action attribute. The input tag lets Firefox know the value should come from user input and that it should be named p, as in the Yahoo! Image URL.


O'Reilly Home | Privacy Policy

© 2007 O'Reilly Media, Inc.
Website: | Customer Service: | Book issues:

All trademarks and registered trademarks appearing on oreilly.com are the property of their respective owners.