Chapter 10. Packaging Apps as Bookmarks: Bookmarklets and Data URLs
Because iPhone and iPod touch applications function inside of the Mobile Safari environment, there are two seemingly obvious restrictions for the Web developer: You must live with the built-in capabilities of the Mobile Safari browser; and you need a constant Wi-Fi (or, for iPhone, EDGE) connection in order to run any application.
The truth is that you can get around these limitations by taking advantage of two lesser-known technologies — bookmarklets and data URLs. These technologies have actually been around for years, but they have tended to exist on the periphery of mainstream Web development. However, developers are now reexamining these two developer tools to maximize the potential of the iPhone application platform.
Bookmarklets (short for bookmark applets) are mini JavaScript "applets" that can be stored as a bookmark inside of Safari. A data URL is a technique for storing an entire Web page or application (pages, styles, images, data, and scripts) inside of a single URL, which can then be saved as an iPhone/iPod touch Bookmark. This application-in-a-bookmark can then be accessed in offline mode.
Bookmarklets
A bookmarklet is JavaScript stored as a URL and saved as a bookmark in the browser. It is typically used as a one-click applet that performs a very specific task or performs an action on the current Web page. A bookmarklet uses the javascript:
protocol followed by script code. For instance, here's the simplest ...
Get Professional iPhone™ and iPod® touch Programming: Building Applications for Mobile Safari™ now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.