• United States

How to save JavaScript code fragments as Bookmarklets

Jun 25, 20032 mins
Enterprise Applications

* Bookmarklets originate from Netscape

I wrote about the topic of bookmarklets a long time ago (1999!) in my Network World Gearhead column (see links below). Curiously enough, I’ve not seen much written on the topic since. But as a Web application developer this is a really clever idea that could be of great value to you.

Bookmarklets are fragments of JavaScript code that are saved as bookmarks. By selecting the bookmarklet from the Favorites menu you are able to do a remarkable number of useful, informational, or entertaining things.

For history buffs, the origins of bookmarklets lie in the work done by Netscape engineers to developed JavaScript – they conceived of the possibility way back when. Smart guys.

Here’s an example of a bookmarklet (originally formatted as a single line):


            {alert(‘The server indicates that the page was last

             modified: ‘ + window.document.lastModified)}


            {alert(‘Page is framed. Use version of bookmarklet

             for frames. (’)}

This code checks the last modification date of a Web page and shows a number of attributes of bookmarklets. First, the method for a bookmarklet is “javascript:” which tells the browser that the rest of the URL is to be handed to the JavaScript interpreter.

Note the test “if(frames.length

And therein lies the next big issue: Browser compatibility. Again, lack of space makes complex coding impossible but there’s also the problem that some browser have features that others don’t.

A good place to find bookmarklets is, not surprisingly, This site offers, for free, more than 150 examples that cover Page Data, Page Look, Search tools, Navigation, Windowing, Special Tools, Calculators and Converters, and Design tools.

Another site that is really useful is Jesse’s Bookmarklet Site which offers, again for free, many technical bokmarklets for content development, link checking and so on.

Let me know if you’re using bookmarklets and if you have any that you find particularly useful.


Mark Gibbs is an author, journalist, and man of mystery. His writing for Network World is widely considered to be vastly underpaid. For more than 30 years, Gibbs has consulted, lectured, and authored numerous articles and books about networking, information technology, and the social and political issues surrounding them. His complete bio can be found at

More from this author