# My favorite bookmarklets

Bookmarklets to search a website, navigate it, and see what links to it.

The recent lifehacker article Ten Must-Have Bookmarklets reminded me that I’ve developed a few handy ones myself. A bookmarklet (“bookmark” + “applet”) is a little bit of Javascript embedded in a link. They usually take some information about the page you’re looking at and do something useful with it. For example, if you highlight some text on this page and click this demo it displays the highlighted text in a message box. This particular example is not very useful, but it demonstrates how a bookmarklet can grab information from the displayed web page and do something with it. The following shows what’s really in the link:

<a href="javascript:alert(document.getSelection())">this demo</a>


Bookmarklets more complex than this one may define and call functions, but they’re still all packed into a a element’s href attribute. The lifehacker article has one that builds on this use of the getSelection() method by looking up the selected text in an acronym dictionary.

Running bookmarklets on the page that contains them is rarely interesting, but when you keep these bookmarklets in your bookmarks menu (or, more likely, on your bookmarks toolbar), you can run them against anything, which is when they get valuable. You could drag that “this demo” link to your bookmarks toolbar and then highlight text on any web page, click that link, and see the highlighted text displayed in a message box, but you’d be better off dragging the more useful ones below to your toolbar:

• site’s homepage goes right to a particular site’s homepage—for example, to http://www.snee.com from this page.

• search site lets you search the website of the displayed page with a minimum of keystrokes. Click it to display a search form with one field (for example, this form if you were looking at the lifehacker article), fill out that field with a string to search for, click “Go,” and Google searches that site for you.

• cd .. goes to the parent directory of the displayed page’s directory.