2. Once the functionality works as expected, drag the javascript: URL onto your Bookmarks
bar in Safari. If you are going to have a set of bookmarklets, you may wish to create a special
Bookmarklets folder to store these scripts.
Or, if your bookmarklet is contained within the href of an a link, then drag the link onto the
Bookmarks bar instead.
3. Synch the bookmarks of your iPhone and main computer through iTunes.
4. Access the bookmarklet in the Bookmarks inside Mobile Safari (see Figure 10 - 2 ).
Figure 10-2: Accessing a bookmarklet from iPhone
Chapter 10: Packaging Apps as Bookmarks: Bookmarklets and Data URLs
224
Alternatively, you can add a bookmarklet directly into Mobile Safari ??™ s Bookmarks by creating a link to
any normal Web page, and then editing the URL of the bookmark.
Exploring How Bookmarklets Can Be Used
While bookmarklets can be used for these sorts of general purposes, their real usefulness to the iPhone
application developer is turning JavaScript into a macro language for Mobile Safari to extend the
functionality of the browser. For example, Mobile Safari always opens normal links in the existing
window, replacing the existing page. Richard Herrera from doctyper.com wrote a bookmarklet that
transforms the links of a page and forces them to open in a new tab.
Pages:
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259