WebOS uses the concept of cards as it’s main UI element. Each application exists in a card, applications can even open up multiple cards. For example, if you had the Map app and Browser active on your webOS device, both apps would exist in their own instance of a card.
Cards on the webOS interface.
To open a new card in PhoneGap-0.9.5 webOS you will need to call the newCard API.
The newCard method takes the following parameters:
- url – url that should be loaded into the new card
- html (optional) – html string that the new card should render
The following example will demonstrate a few different ways to create new cards in PhoneGap webOS. If you’ve never worked with PhoneGap-0.9.5 WebOS; I would strongly recommend that you follow through my Getting Started with PhoneGap-0.9.5 WebOS tutorial.
The following example shows how to:
- load a local html file into a new card
- load an external url into a new card
- load inline html into a new card
Set up a new PhoneGap webOS project and modify the index.html so that it matches the code sample provided below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
Next create a new html file called newcard.html in the same directory as your index.html. Update the source of the newcard.html file so that it matches the following:
1 2 3 4 5 6 7 8
<html> <head> <title>New Card Example</title> </head> <body> New Card content goes here. </body> </html>
The source for the example can be downloaded here.