HTML5 provides mobile device users richer web applications and improved usability. The new features of HTML5 standardize the use cases and technologies that are common in smartphone-optimized mobile web applications. In today’s Mobile Web of WML or XHTML-MP or HTML 4 documents, these features are implemented using proprietary device and browser APIs. With HTML5, advanced web application features are available in all mobile browsers supporting the markup language, using the same standard syntax and displaying the same standard behavior.[1] In December 2011 research firm Strategy Analytics forecast sales of HTML5 compatible phones will top 1 billion in 2013.[2]
Contents |
The AppCache and database make it possible for mobile developers to store things locally on the device and interruptions in connectivity will not affect the ability for someone to get their work done.[3]
Offline support helps browsers cache static pages. They depend more on HTTP response headers sent by web servers to fetch HTML, CSS and multimedia required to render the web page. If everything required to render is cached, then a page loads quickly, but even if one item is not cached then everything slows down dramatically.
To provide offline support, the first offline manifest should be created, and should then be connected to a browser. Finally MIME should be set on the server.[4]
Manifest file lists all files required for an application to run properly. Following manifest file contains comment at the top of file. Having something like a comment is important for the browser to check updates in a manifest file.
CACHE MANIFEST # Version 0.1 offline.html /iui/iui.js /iui/iui.css /iui/loading.gif /iui/toolbar.png /iui/whiteButton.png /images/gymnastics.jpg /images/soccer.png /images/gym.jpg /images/soccer.jpg
After tthe manifest file is created, it should be connected to a web browser. This is done using the “html” element with a manifest attribute. The value of the manifest attribute is the URL of the manifest file.
<html manifest="manifest.mf">
However, the specification for a cache manifests makes the browser to do an additional validation step when it downloads and processes a cache manifest. It must check the MIME type of the cache manifest, and that type must be text/cache-manifest.[4]
Sites can mark off a space on a page where interactive pictures, charts and graphs, game components, and other imaginations can be drawn directly by programming code and user interaction — no Flash or other plug-ins are required.[5]
It's in the very early stages and subject to format disruption, but sites like YouTube and Pandora could one day skip Flash entirely and bring streaming audio and video, with timed playback and other neat features.[5]
This is actually not part of HTML5, but is a separate specification. The geolocation API lets you share your location with trusted web sites. The latitude and longitude are available to JavaScript on the page, which in turn can send it back to the remote web server and do fancy location-aware things like finding local businesses or showing your location on a map.[6]
Following is the prominent API for a geolocation.
navigator.geolocation.getCurrentPosition(successCallback, errorCallback, options);
Geolocation is an object which is part of Navigator object. It uses the getCurrentPosition() method. Finding location is an asynchronous operation as it requires the user’s permission for access. Hence callback functions for success and failure are required.[7]
This example demonstrates a Twitter search to find the latest tweets within 50 miles radius of identified location with the given search keyword. When user enters search keyword, it first checks whether the geolocation functionality is available for the device and if the callback is successful then getCurrentPosition() is used to find the position. The searchTwitter() function is then called with position as parameter. Using position, latitude and longitude is added to the Twitter search query. To call Twitter, a dynamic script tag is used which is often referred to as JSONP.
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width = device-width" /> <title>Local Twitter Search</title> <script> <!--//--><![CDATA[//><!-- function startSearch(){ var gps = navigator.geolocation; if (gps){ gps.getCurrentPosition(searchTwitter, function(error){ alert("Got an error, code: " + error.code + " message: " + error.message); }); } else { searchTwitter(); } } function searchTwitter(position){ var query = "http://search.twitter.com/search.json?callback=showResults&q="; query += $("kwBox").value; if (position){ var lat = position.coords.latitude; var long = position.coords.longitude; query += "&geocode=" + escape(lat + "," + long + ",50mi"); } var script = document.createElement("script"); script.src = query; document.getElementsByTagName("head")[0].appendChild(script); } //--><!]]> </script> </head> <body> <div id="main"> <label for="kwBox">Search Twitter: </label> <input type="text" id="kwBox" /> <input type="button" value="Go!" onclick="startSearch()" /> </div> <div id="results"> </div> </body> </html>
Even simple things like the improvements in HTML5 for forms could make life easier for mobile applications. Fields that can be validated by the browser are improvements for mobile devices. The more that can be handled by the browser means less time downloading JavaScript code and fewer round trips to the server if validation can be found before the form is posted.[5]
The following example is a mobile web form for golf score keeping. Main idea is to avoid pencil and scorecard at golf course. To make scripting easy jQuery hosted by Google is used. HTML5 web form types such as “Placeholder”, “type”, “min”, “step” are included in this example.
<!DOCTYPE html> <html> <head> <title>Golf score keeper</title> <script src="http://www.google.com/jsapi"></script> <script> google.load("jquery", "1.4.1"); </script> </head> <body> <form action="upload.html" method="get"> <div> <label for="1">Hole 1</label> <input type="number" min="1" value="4" name="1" size="2" step="1" /> </div> <div> <label for="2">Hole 2</label> <input type="number" min="1" value="4" name="2" size="2" step="1" /> </div> <div> <input type="email" placeholder="Enter your email address" size="40"/> </div> <div> <input type="submit" value="Upload Score" /> </div> </form> </body> </html>
A Mobile Web Metrics Report demonstrates HTML5 capabilities in mobile devices.[10] The report checked how many HTML5 features are supported by different devices that access the mobile web.
GeolocationAPI, offline web application support, WebStorage, CSS3 Selectors and 2D animations are the top five supported features referred to by the term HTML5 across the top 15 mobile devices in all USA, UK, Germany, Malaysia, Australia markets examined.
Misc. Element types and attributes, extended user interaction concept, CSS3 in General, extended form concept, and extended video / audio support are the top five partially supported HTML5 features across the top 15 mobile devices in all USA, UK, Germany, Malaysia, Australia markets examined.
Microdata, 3D animation rendering, FileReader API, IndexedDB, and local Device support or the WebWorkers feature respectively are the top five HTML5 features not supported across the top 15 mobile devices in all USA, UK, Germany, Malaysia, Australia markets examined.
This report concludes that HTML5 is a welcome addition to the mobile party, but it does not negate device and OS fragmentation.[11]
With HTML5 and mobile web development new tools and frameworks are popping up to provide a more consistent and comprehensive HTML5 support across mobile browsers. Such HTML5 mobile web frameworks are:
jQuery Mobile, is A unified user interface system across all popular mobile device platforms, built on jQuery and jQuery UI.[12]
Sencha Touch is the first HTML5 framework for mobile devices. This framework builds web applications that make sense for mobile devices. It comes with a comprehensive UI widget library, complete touch event management with CSS transitions and an extensive data package.[13]
SproutCore, is an open source HTML5/JavaScript for building web and mobile apps. Through the use of Phone Gap, SproutCore applications can be wrapped into native apps that run on iOS, Blackberry and Android platforms.[14]
The-M-Project is an HTML5 JavaScript framework that targets iOS, Android, BlackBerry and webOS platforms. It makes use of jQuery on the JavaScript part and contains all UI and core files with features like offline support, internationalization and more.[15]
A jQuery plugin for mobile web development on the iPhone, iPod Touch, Android 2.3+, and other forward-thinking devices. This framework is heavy on the CSS, while light on the JavaScript.[16]
Jo is a JavaScript framework for HTML5 capable browsers and devices. It was originally designed to work on mobile platforms as a GUI and light data layer on top of PhoneGap. Since its creation, Jo has also been tested successfully as a lightweight framework for mobile browsers, newer desktop browsers, and even dashboard widgets.[17]
DHTMLX Touch is an HTML5-based JavaScript library for building mobile web applications. It is not just a set of UI widgets, but a complete framework that allows you to create eye-catching, cross-platform web applications for mobile and touch-screen devices. The framework is compatible with the major web browsers for mobile platforms. Applications built with DHTMLX Touch will run smoothly on iPad, iPhone, Android-based smartphones, and other popular devices.[18]
WorkLight is a mobile application platform that supports the development of HTML5, hybrid and native mobile applications. The WorkLight Studio - the platform's IDE - allows mobile developers to make full use of all existing HTML5 functionality as well as further enhance these capabilities with utilities and mechanisms required by modern organizations such as encryption of locally stored data, offline authentication, combined HTML5 and native coding, 3rd-party library integration with frameworks such as PhoneGap, Sencha Touch, JQuery, and more.[19]
MobileNationHQ is a web based tool that uses a visual programming paradigm to facilitate the creation of HTML5 mobile applications for iOS and android. The tool also supports the integration of custom javascript[20]
BkRender is a HTML5 framework for cross-platform mobile development (iPhone, Android, BlackBerry, Windows Phone, Bada, WebOS, tablets etc.).[21]
iOS is Apple's operating system that powers iPhones, iPod Touches, and iPads. iOS 3.2 has a number of issues with HTML5 video.
poster
attribute. The poster attribute of the <video> element allows you to display a custom image while the video is loading, or until the user presses “play.” This bug is fixed in iOS 4.0.Android is Google's operating system that powers a number of different phones and handheld devices. Versions of Android before 2.3 had a number of issues with HTML5 video:
type
attribute altogether and ensure that your H.264+AAC+MP4 video file’s name ends with an .mp4 extension. You can still include the type
attribute on your other video sources, since H.264 is the only video format that Android 2.2 supports. (This bug is fixed in Android 2.3.)controls
attribute was not supported. There are no ill effects to including it, but Android will not display any user interface controls for a video. You will need to provide your own user interface controls. At a minimum, you should provide a script that starts playing the video when the user clicks the video. This bug is also fixed in Android 2.3.[22]