Published on: Sunday 4th July 1999 By: Martin Webb
Bookmarklets are simple tools that extend the surf and search capabilities of Netscape and Explorer web browsers.
Steve Kangas - "Chief of Rocket Science" - Bookmarklets.com
Wherever you browse the WWW, the chances are you'll come across a site that does something you don't like: opens new windows, displays white text on a black ground, etc. Until you've visited the site, you'll not know what it is that you'll not like. And once you've visited, its too late to change anything.
Wouldn't it be nice to actually alter the look of a site, extract data from a page, search the web and navigate in new ways?
If you are using one of the appropriate browsers, why not type the following into the location bar right now:
However, after typing that out a few times, you might find yourself putting up with orange text on a red background. This is where the bookmarklet idea comes into its own.
which looks like:
and then just bookmark the above links:
You'll now have two bookmarklets which can be used to alter the background color of any web page.
Unlike normal bookmarks, which include the documents title text, the bookmarked links use the link URL as the description of the bookmark, however, once bookmarked it is possible to manage/edit your bookmarks to give them a more user friendly description.
Bookmarklets act on the windows document, this means that if the window contains a frameset then there is a possibility that a bookmarklet will fail to achieve its objective, e.g. changing the background color, as it will attempt to change the background color of the window and not one of the framed documents. It just depends on what the bookmarklet is attempting to do. For example, a bookmarklet to place the URL of the window in the body of an email message would work perfectly:
It is possible to make bookmarklets compatible with frames - although you'll probably want one version for non framed pages, and another for framed pages - you just need to add frame navigation to your bookmarklets. For example, to change the background color of any frame within a frameset, you could add a prompt to confirm which frame you wish to change:
It's also possible to write a recursive script that descends through the frames. For an example, see the code for Page Freshness (Frames version) at http://www.bookmarklets.com/tools/frames.phtml#pgfrshfrm
It is also possible write bookmarlets that will only work correctly on the latest browser versions. For example, to get feel for how long a document is the following bookmarklet will calculate how many windows the current document fills:
As it stands it will only work in Netscape Navigator 4+, but another bookmarlet could be written for Microsoft Internet Explorer 4+:
You just bookmark the appropriate bookmarklet for your browser, although if you are adventurous, you could always create bookmarklets that handle both browers at once:
As Steve himself says "the limit on the number of characters [in a bookmark] is difficult to answer", although "Netscape on Macintosh will not accept bookmarks longer than 507 characters, and may have trouble with bookmarks longer than 255 characters." Currently Steve uses a maximum of 256 characters for all the bookmarklets at Bookmarklets.com. Although he hopes to be able to extend this self imposed limit based on feedback received to 1000, 2000 and then perhaps 4000 characters.
This article has only been a short introduction into the use of bookmarklets. Bookmarklets can be used to scroll through a document, hide and display images, alter the text font and color (MSIE4+ only), manipulate selected regions of text in the document, examine and manipulate the links in a page, manipulate windows - they are limited only by your own imagination.
My personal favourite is the following simple bookmarklet that resizes the window to 640x480 pixels (so that I can check what a page looks like at a smaller resolution):
Simple, but extremely effective.
I would strongly suggest visiting the Bookmarklets.com web site run by Steve Kanga, as there are over 150 bookmarklets just waiting to be bookmarked.