Organise

Create Smarter Keyword Bookmarks


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://www.lifehacker.com.au/search?query=%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.

javascript:if('%s') location.href='http://www.lifehacker.com.au/search?query=%s';else location.href='http://www.lifehacker.co.aum/';

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!

Comments (AU Comments | US Comments)

    There are currently no AU comments for this post.

Post Your Comments

Got something to say? There are two ways to comment:

1. Guests

Click here to comment instantly.

2. Facebook Users

Click below to comment using your Facebook account.

We're looking for comments that are interesting, substantial or highly amusing. If your comments are excessively self-promotional, obnoxious, or even worse, boring, you will be banned from commenting. All comments are moderated.