Favelets/Bookmarklets

Favlet and bookmarklet are two alternative names for the same thing derived from the fact that Internet Explorer Favourites are effectively the same thing as bookmarks in other browsers.

Favelets (I'll call them that because the name is shorter and so involves less typing) are special programs written in javascript but they don't execute in the page that contains them. Favelets are attached to a link in the page but they although they can be executed by selecting the link, that is not the way they are intended to be used. Favelets (as you might guess from their name) are intended to be transferred to your browsers favourites (or bookmarks) menu and run from there. This allows you to execute the attached javascript against any web page just by selecting the option from the menu. You can even add them to your Links or Personal Toolbar giving you a visible reminder on your toolbar of what favelets you have already installed.

Before you grab a favlet to add to your browser, you might first want to test the effect of the favlet on the page where it is supplied. You do this by selecting the link that the favlet is attached to. This will execute the favlet against the page containing it and assuming that the page contains something that the favlet affects, you will see what the favlet does. If the page doesn't contain anything that the favlet affects then you will still not know whether the favlet works or not. Testing the favlet like this is the only time that you would left click on the favlet link.

There are two ways to attach a favlet to your browser. The simplest if you have the Links or Personal Toolbar showing in your browser window is to simply right click the favlet and drag it onto the toolbar. The alternative is to right click the favlet link (or use the keyboard to select the link and then access the context menu). You then select Add to Favorites (in Internet Explorer), File Bookmark for Link (in Netscape 6+), or Add Link to Bookmarks (in Opera) to transfer the favlet to your favorites/bookmarks menu.

Not all favelets will actually work with all browsers. Netscape 4 doesn't allow you to add favelets to your bookmarks menu at all, Internet Explorer 4 and Opera 5 don't support them either. Whether a particular favlet will work in a given browser that does support favelets depends on which commands that the javascript contains and whether or not the particular browser supports those commands. Most favelets use the Document Object Model to access (and perhaps change) the source of the current page. Support for favelets therefore varies depending on the DOM support available in a given browser.

Enough discussion of favelets, let's take a look at an actual favlet so that you can see for yourself how simple it is to add one to your browser and use it.

The above favlet is one that I have written as an example for this page. It works in Internet Explorer and Netscape (you can install it in Opera 6 or 7 but it doesn't work there). What the favlet actually does when you execute it against a given web page is to remove all of the image references from the page source which will make all of the images disappear. Images included in the page using the <img> tag are affected (including invisible images used for page layout) but images attached to other html statements (such as background images) will not be affected. The script only works against the main html file for the page and external javascripts linked into that file so it can't work on pages within a frameset (but it tests for this and tells you). The images aren't just hidden, they are actually removed from the page source so any scripts in the page that reference those images will give errors. The script only affects the current page, the next page to be loaded will display all of its images (so you can bring back the images in the current page simply by refreshing/reloading the page).

Most favelets will not give you as detailed a description of what the favlet does and its limitations as I have just given you for this one so you may have to find out by trial and error just exactly what the favlet can and can't do before you decide whether the favelet is as useful as it might at first appear to be.

The actual limit for the length of a favlet as far as I am able to determine is 606 characters. Favelets longer than this may work in some browsers but will be truncated (and therefore not work) in others. From what I have read, this limitation does not appear to apply on the Apple Mac and so many favelets developed on the Mac will not work on Windows because they are too big.

One final thing to watch for. Most favelets are written using javascript. These are fairly safe to run because they are limited to those functions that can be performed by javascript. Javascript has no access to files and so can't harm anything on your computer. There are some favelets that are written with ASP (or another server side language) instead of javascript. I suggest that you be very careful about using such scripts as these do not have the same limitation on access to files on your system that javascript does.

 

This article written by Stephen Chapman, Felgall Pty Ltd.

go to top

FaceBook Follow
Twitter Follow
Donate