This section discusses concepts and frameworks for making JavaScript tools available beyond a web developers own web site into the Internet Cloud in general. Obviously, one way to do this is to make your code available for download and that is still the best way to make your code available to other developers. However, several developments in browser and Internet portal technology over the past several years to make this easier without asking users to consciously download your JavaScript libraries.
Bookmarklets are probably the simplest way to make your JavaScript code available outside your web site. They are a very simple concept that involves putting JavaScript in hyperlinks and then saving those hyperlinks to bookmarks in a browser. There are a number of bookmarkets available on the web to do useful things, such highighting text on a page, searching text on a site using Google, JavaScript development, and so on. In fact, a lot of what you can do using Firefox browser extensions can be done using bookmarklets and be made available in IE simply and easily. Flanagan [FLAN] mentions bookmarklets in the JavaScript Definitive Guide and you can read more about them and get some bookmarkets from Jesse's Bookmarklets [RUDE]. These are bookmarklets on this site for Chinese text search and dictionary lookup. They are located at the page bookmarklets.php.
Bookmarklets take advantage of being able to embed JavaScript in hyperlinks, being able to bookmark the hyperlinks, and then executing the JavaScript later from the browser bookmark menu or toolbar. The page bookmarklet_example.html demonstrates the simplest possible bookmarket. Try bookmarking the link (in Firefox you can drag the link to the toolbar) and clicking it. The code is
When the bookmark is clicked it pops up an alert box with the text 你好!The void 0;
is needed to stop the current page being overwritten. This is a trivial example but the power
of this technique is that the executing JavaScript can read and manipulate the page that the
user is viewing, which is not usually the page that the user found the bookmarklet on.
Copyright Alex Amies 2008. Please send comments to alex@chinesenotes.com.