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 of examples:
javascript:alert(???iPhone??™)
Chapter 10: Packaging Apps as Bookmarks: Bookmarklets and Data URLs
222
Because the scripting code for a bookmarklet is housed inside of a URL, the script must be condensed
into one long string of code. Therefore, to enter multiple statements, separate each line with a semicolon:
javascript:alert(???Bookmarklet 1??™);alert(???Bookmarklet 2??™)
As you can see, there are spaces inside each of the strings.
Pages:
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257