Article
You Don't Know Jack About Firefox!
Smart Keywords
Smart Keywords are a great way to perform search queries from the location bar. With smart keywords, you can type dict extemporaneous into the location bar, hit Enter, and be taken to the Dictionary.com definition of "extemporaneous." The hard way to do this is to go to Dictionary.com, wait for it to load, click on its search box and enter extemporaneous. Bah! That takes too many steps.
Firefox comes with several Smart Keywords automatically installed. You can find them in the Quick Searches folder in your bookmarks, as illustrated in Figure 2.18. You don't have to use this menu at all—it's just an easy way to see which Smart Keywords are installed.
Figure 2.18. Firefox's pre-defined Smart Keywords offering.

The predefined Smart Keywords are:
- Dictionary.com
Type
dict wordto lookup the definition of a word. - Google
Type
google search keyword(s)to perform a normal Google search. - Stock Symbol
Type
quote symbolto look up stock quotes for a stock symbol. This content is sourced from Yahoo! Finance by Google. - Wikipedia
Type
wp anythingto access the Wikipedia entry on just about anything (Wikipedia is a free online encyclopedia). - Urban Dictionary
Type
slang slang wordto look up the meaning of urban slang words, and keep up with the times!
I'm sure you're wondering how Smart Keywords are created. After all, it would be nice to construct additional keywords for searches that Firefox has not already provided for you. There are two ways to create a Smart Keyword: the easy way, and the hard way. The easy way is preferred, but when it occasionally fails, you'll have to fall back on the hard way. Let's look at both, starting with the easy way.
Let's add a Smart Keyword for A9, Amazon's relatively new search engine. First display A9's homepage. Right-click in the search box, and you should see the context menu item Add a Keyword for this Search…, as shown in Figure 2.19.
Figure 2.19. Adding a Smart Keyword from a search field.

The last item on the menu looks like the one we're after, and indeed it is. When you pick that item, an Add Bookmark dialog will appear, prompting you to fill in the name of the bookmark as well as the keyword. Let's name it A9 keyword and use a9 for the special keyword. Save the result in a bookmark folder of your choice—I recommend you save it in the Quick Searches folder with all the other predefined Smart Keywords.
When you're done, you can try it out straight away. Enter a9 firefox, and you'll be taken to the A9 search results for the "firefox" search term that you entered. Great! We're making progress.
Now, let's try doing this same task the hard way. We're not doing this just so we can say we've done it to impress fellow guests at dinner parties. We're doing it because the easy way doesn't work.
For example, go to the Yahoo! search engine, and try to add a Smart Keyword the easy way. Nothing happens: no Add Bookmark dialog appears—at least, not as this book goes to print. (Technically, this is because the Yahoo! Search text field is not specified with id="search").
Perhaps Yahoo! will fix this someday. Perhaps it will already have been fixed by the time this book lands in your hands: such is the nature of the Internet. Fixed or not, it's clear that many Websites do not support the easy addition of Smart Keywords.
To add a Smart Keyword the hard way, you must first study Web addresses a little. Type a query into the search box, hit Enter, and look at the URL that's generated. We need to pull that URL apart for our own purposes. If we use the Yahoo! Search search engine to search for "firefox," the resulting search URL looks like this: http://search.yahoo.com/search?ei=UTF-8&fr=sfp&p=firefox. Those who are familiar with URL query strings, and understand how certain search engines work, will recognize that only http://search.yahoo.com/search?p=firefox is necessary to perform the search. The rest is extra information for Yahoo!, like the character encoding for your search query and where you conducted the search.
Replace the search query ("firefox") in that URL with %s to create a URL that's suitable for a Smart Bookmark. A Smart Bookmark is a special bookmark that is used to define a Smart Keyword. Firefox recognizes "%s" as a placeholder for your keyword, and replaces it with your typed information whenever you perform a Smart Keyword search. If you enter two or more words, possibly separated by spaces, Firefox treats them all as a single keyword string. So you can only use "%s" once.
To create the Smart Bookmark, we bookmark the search page (the ordinary search page for the search engine in question), then modify the new bookmark. We change the bookmark's name to something better, like "Yahoo! QuickSearch," and tweak the bookmark so that it acts in a Smart Keyword-like manner. We then save the bookmark in the QuickSearch bookmark folder.
To do all this, find the new bookmark in the Bookmarks menu, select it, right-click, and select Properties. Figure 2.20 shows the menu that holds the Properties item.
Figure 2.20. Displaying a plain bookmark's properties.

Choosing Properties should bring up the bookmark properties dialog, in which we can make all the required edits. Update the name, replacing "firefox" with the special %s placeholder, and provide a keyword (I chose "y" for "yahoo"). You can also add a description if you wish. Figure 2.21 shows these changes.
Finally, click OK, and there you have it: a Smart Keyword for Yahoo! Search. Try it out for kicks.
Now that you're armed with enough knowledge to create Smart Keywords the hard way, you can use it to do some innovative and interesting stuff. Let's create a currency conversion Smart Keyword that converts from European Euros to US Dollars. Using the service at XE.com, let's try to do this the hard way.
It turns out that this task is even more challenging than usual. Web developers will understand me when I say that the xe.com currency converter normally uses HTTP POST for form submission, instead of HTTP GET, so there isn't a URL that we can exploit: one into which we can insert the "%s" placeholder we used before. POST (or rather, HTTP POST) is a method of passing data to a Web page (or rather, a Web server). The Smart Keyword system can only use URLs based on GET requests. Non-developers probably won't understand this technicality, nor should they have to. The upshot is that we need to find a GET request that we can use as the basis of our Smart Keyword.
Figure 2.21. Specifying the Yahoo! Quicksearch Smart Bookmark properties.

To do so, we have to dig into the HTML source of the Web page that performs the search (from the menu, choose View > Page Source, then start tearing your hair out!). With a little digging into the HTML source of the http://www.xe.com Web page, we can deduce that a useful Smart Keyword URL would be: http://www.xe.com/ucc/convert.cgi?Amount=%s&From=EUR&To=USD
We bookmark that URL, and edit the bookmark properties, remembering to give it a keyword: "e2u" is a good choice. To test out the new keyword—for example, to find out how much one million Euros is worth in USD—type e2u 1000000 in the location bar.
If you know how to sift through HTML source, life is great; if you don't, life isn't so terrible. A little help from someone else is all you need. Here are some other Smart Keywords that you might consider.
- Google I'm Feeling Lucky
- Altavista
- Amazon
- Google News
- Google Groups
- eBay
- Feedster recent blog posts
- The Internet Movie Database
- Thesaurus.com
- CiteSeer (Computer and information science publications database)
The basic premise behind the Smart Keyword feature is very simple: it simply replaces the "%s" placeholder with the keyword that you type in. Armed with this knowledge, you can make a Smart Keyword for just about any Web service that has a variable component in its URL.
Right-Click Text Searching
I started this section by saying that TIMTOWTFI (There Is More Than One Way To Find It). Then, we searched for the text "blogosphere." That technique is called "text search," and it's something that bears a little further exploration.
To perform a text search, you must master two mouse gestures: highlight, and context select. Highlighting text is easy—for simple operations, at least. To do so, click before the required piece of text, then, holding the left mouse button down, drag the mouse over the text to create the highlight. Release the mouse button to finish the highlight. When you do the context-selection (right-clicking on the highlighted content), you'll see a Search Web for "whatever you selected" item appear in the context menu, as shown in Figure 2.22.
Figure 2.22. Convenient search from the context menu.

If you left-click on this menu item (I dare you to!), Firefox will perform a search for the selected text on Google in a new background tab. Yes: on Google, again!
Text search isn't restricted to text, either. If you highlight an image on the page (by clicking just outside the left edge of the image, then dragging across it), the context menu will provide a search based on any alt (descriptive) text that's specified with the image. Alas, if the image is provided as part of a style, you can't do this yet; the image must be a proper part of the page.
You can also perform a highlighted search for text that appears in a link. Highlighting text in a link is quite tricky, though: you might accidentally start a download or open a tab if you try to drag-highlight across such text. Instead, start by highlighting the text with the Find Links As You Type feature (discussed next as part of the section called "FastFind: Find As You Type"). Once the text is highlighted, bring up the context menu by right-clicking on it as you would for any highlighted text.
As yet, you can't perform a text search on text inside a textbox or a text input field, but that feature may come in future.
What if you don't want to use Google as the default search engine? A bit of geek-speak is required to change that. You might like to read Chapter 6, Tips, Tricks, and Hacks before experimenting, though.
Type about:config into your Firefox address bar, hit Enter and look for the browser.search.defaulturl preference in the displayed set of preferences. Its value should be set to: http://www.google.com/search?lr=&ie=UTF-8&oe=UTF-8&q=. Replace this string by right-clicking on the preference. Use http://search.yahoo.com/search?p= for a Yahoo! search, or the equivalent string for another engine. Note that "%s" is not required in this case.
FastFind: Find As You Type
Other than searching for a Web page, you will often find yourself searching within a Web page. This is especially so for Web pages that contain lots of (largely irrelevant) content, for long listings, and when you're looking for a specific piece of information.
Firefox has an easy to use über-feature called FastFind. This is the official marketing buzzword; it's also known among veteran Firefox users as Find As You Type (FAYT), or Type-Ahead Find. Find As You Type does exactly what it says: it finds text as you type. How does it work? Just hit / (forward-slash) or Ctrl-F, then start typing the word (or words) you're looking for. Firefox will find and highlight the first instance of the word(s) that matches what you've typed, from the second you start typing. The easiest way to see what I mean is to try this out for yourself. Go to the Mozilla site and type /firefox as soon as the page has finished loading.
You can also use F3 or Ctrl-G to find the next match on the page, and Ctrl-Shift-G to find the previous match. So there's no need to take your hands off the keyboard, and no need to deal with a pesky Find dialog window that gets in the way! Instead, you get an unobtrusive Find toolbar at the bottom of the page, as shown in Figure 2.23.
Figure 2.23. The Find toolbar.

This is one of my favorite Firefox features. When I occasionally use Internet Explorer, I often lapse into hitting / and typing text in an attempt to search for stuff. Alas, this feature doesn't work in IE…
If you're daunted by having to remember keyboard shortcuts, have no fear: the Find toolbar is here (so much for poetry). Whenever you start a find, the toolbar springs into existence at the bottom of the page. You can use the buttons on the Find toolbar to find the next or previous matches. I recommend you get used to the keyboard shortcuts though, because they really speed up the searching process.
Perhaps you noticed the Highlight button in the Find toolbar. You can use this to highlight all text that matches your search word(s). The keyboard shortcut for this is Ctrl-Enter. Figure 2.24 shows what this looks like.
Figure 2.24. Highlighting "Firefox" through the Find toolbar.

This kind of highlighting uses yellow to mimic the action of a felt pen highlighter, and doesn't change your current selection. There's also a checkbox that you can check should you want to match case (i.e. typing FiReFoX will match "FiReFoX" but not "Firefox" or "firefox").
Tip
There are probably times when you want to search only within the text of links, ignoring all the other text on the page. A good example is my endless scanning for the "download" link on a Web page. To start searching only within links, hit ' (single apostrophe), instead of the usual / (forward-slash) or Ctrl-F, then start typing as you normally would. Only link text that matches your search term is highlighted. When you come to a link that you want, you can use Enter to load it in the current tab, or CtrlEnter to load it into a new tab.
A final variation that improves the efficiency of your searching is to enable the preference Begin finding when you begin typing, which can be found under Tools > Options > Advanced >Accessibility (Firefox >Preferences on Mac OS X, Edit >Preferences on Linux). That option's shown in Figure 2.25.
When this preference is enabled, you no longer have to hit / or Ctrl-F to start a search: just start typing your search phrase! This used to be the default behavior prior to Firefox 1.0, and is a well-loved feature among power users, yours truly included.
Figure 2.25. Begin finding when you begin typing.

Search is what you do with a browser when you want to find something. But, what do you do when you're presented with information that you'd rather not know? We take a look at this issue next.