Viewers
With Mojo, you can embed rich media objects within your scenes. There are widgets for a web object, a full screen image scroller, and partial support for HTML 5 audio and video tags for inclusion of audio and video objects.
WebView
To embed a contained web object, declare and instantiate a
WebView
widget. You can use it to render local markup or to load an
external URL; as long as you can define the source as a reachable URL,
you can use a WebView
to render that
resource.
Back to the News: Adding a web view
Tapping on a story will push a web view scene and load the original story’s URL in that scene. This example is a simple use of Web view, where we create a new scene for the web page, but it’s still within the News application’s context.
Create a new scene, called webView, using palm-generate
, then declare the widget in
your scene view and configure it in your scene assistant before
calling setupWidget()
. The
storyWeb-scene.html is just one
line:
<div id="storyWeb" x-mojo-element="WebView"></div>
And there’s not much more to the storyWeb-assistant.js to configure and set up the WebView widget:
/* StoryWebAssistant - NEWS Copyright 2009 Palm, Inc. All rights reserved. Passed a story URL, displays that element in a full scene webview with a load indicator and reload button. Handles link selections within the view. User swipes back to return to the calling view. Major components: Arguments: - storyURL; Selected feed from which the stories are being viewed */ function StoryWebAssistant(storyURL) ...
Get Palm webOS 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.