If you are a fan of Firefox's keyword bookmarks, you might have noticed that using a search bookmark without a search term will typically lead you to a "No Results Found" error page—annoying, but fixable.

Reader Rupert writes in with an excellent tip that can be used to create smarter search bookmarks—but requires a little bit of javascript editing. The general idea is that the javascript can be used to detect whether or not you entered a search term, and navigate to the home page of the site rather than the search page.

For instance, to search Lifehacker by using "lh <keyword>" in the address bar, your keyword bookmark location would normally look like this:

http://lifehacker.com/search/%s

If we don't have a search term, though, we want to just navigate to the home page instead, so we just plug this javascript into the location box—the little bit of "if" logic in there is where the magic is, as it detects whether the %s parameter has been passed into the keyword bookmark.

With this solution you can search Lifehacker in the address bar with "lh <keyword>", or just use "lh" in the address bar to navigate directly to the site—the same technique could be applied to any bookmarklet. Thanks, Rupert!