Search site bookmarklet with YUI and BOSS
Ever wanted to search only the web site you're currently on? Not the page, but the whole site. And only this site, not the rest of the web. This bookmarklet does just that.
Install
Right-click this link and add to your bookmarks/favorites. Or just drag to your bookmarks toolbar.
Or if you don't want to add the bookmarklet, you can simply click the link above and try it out.
Use
You can search any site. Just visit the site and click the bookmarklet. There's also keyboard navigation to move up/down the results. The search results display as you type and the first results is highlighted so you can just press Enter and follow the first match of your query.
Here's a short video that shows how you can use the bookmarklet to search my blog.
Under the hood
The bookmarklet uses YUI and BOSS to do its magic.
YUI (Yahoo User Interface) library's Dom, Event and Get utilities make a task like this so much easier.
BOSS (Build your Own Search Service) is a mildly confusing name for Yahoo Search's API second major iteration. The API allows you to specify a site (or sites) that you want to limit your search query.
The bookmarklet simply includes searchsite.js served from here; the bookmarklet was generated with the help of this bookmaker.
Show me code!
It's on GitHub, right here under the searchsite directory, it's just one script file searchsite.js, not at all documented, but I hope you'll make sense of it.
This entry was posted on Saturday, February 21st, 2009 and is filed under BOSS, JavaScript, api, bookmarklets, yahoo, yui. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.
Get notification for future posts: follow me on Twitter or subscribe to my RSS feed

March 2nd, 2009 at 5:07 pm
[...] feed. As always, please let us know in the comments if there’s something important we missed. Stoyan Stefanov’s Site Search Bookmarklet with YUI and BOSS: Stoyan has created a bookmarklet that generates a YUI and BOSS-powered search box for your site [...]
March 2nd, 2009 at 7:37 pm
Silly little tip to go along with this… “Make this bookmarklet your home page” then you can (ab)use the home button to activate it and not have to turn on the bookmark toolbar.
–Robert
March 3rd, 2009 at 8:18 pm
I’ve added this to the top level of my Bookmarks Bar. That might not sound like a big deal, but I add things there about once a year (if that), so that should tell you just how awesome I think this is.
Now it just needs a “Close” box.
March 3rd, 2009 at 8:46 pm
Thanks Mark, coming from you that means a lot to me! Yep a close button (or hitting ESC) would be nice.
Robert, this is crazy, I didn’t know it was possible to abuse the home button like this! I like it. I don’t use the home button anyway.
March 3rd, 2009 at 11:36 pm
[...] Ames commented on my previous post suggesting replacing the Home button with my little site search bookmarklet. I [...]
August 1st, 2009 at 4:36 am
[...] This ones a good idea but a bit limited by the amount of results. Most sites have some sort of search function already but this makes it so you can search without leaving the page youre on. Search site bookmarklet with YUI and BOSS / phpied.com [...]