Great bookmarklet for searching the docs

[UPDATE: I should have posted the bookmarklets themselves for convenience. This one searches the Mac docs: Search Mac. This one searches the iOS docs: Search iOS. Drag these to your bookmarks bar. If you use Safari, you can use Command-(number) for quick access.]

Peter Hosey posted this tip for tweaking Chrome or OmniWeb to easily search the Apple documentation. In the comments, Erik provides a great bookmarklet for doing the same in any browser.

You might guess Peter is doing something obvious like Googling with site:developer.apple.com. But actually he uses Apple's own search, the same as if you went here or here and used the top right search field (not the one farther down). Apple revamped their online doc search a while back to return much nicer and more useful results, as you can see from this screen shot on Peter's article:

Previously I was using Sal Conigliaro's ADC Search Safari extension to perform this search. Sal mentioned ADC Search in response to my earlier post on finding sample code. It adds a search bar that does the same Apple search, and also displays convenient links to key points in the Apple documentation. I added a keyboard shortcut for the menu item that shows and hides the search bar, so it doesn't always have to take up space in the Safari window.

My only nitpick with ADC Search is that I have to click on the search field to give it keyboard focus. (I just sent Sal an email about this; I really should have done so earlier.) Conveniently, in comment #4 on Peter's article, Erik (with some tweaking from Peter) provides a bookmarklet that does not have this drawback because it brings up a search field that already has keyboard focus. Erik actually provides two bookmarklets, one for Mac and one for iOS. I've added them to the beginning of my Safari bookmarks bar and now I can get to them with Command-1 and Command-2.

As I'm typing this I discovered a nitpick with the bookmarklet, which is that if I hit Escape it doesn't cancel the search, but rather does a search for "null". I'm about to mention this in comments on Peter's article; I'm sure it's easy to fix. [UPDATE: Peter has fixed the bug in the bookmarklet. If you grabbed it before, go and grab it again. Also, note that if your search results look like one long list instead of four columns like in the screenshot above, you just need to select the column mode from the buttons on the left just above the search results.]

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.