Posts Tagged ‘HTML 5’

HTML 5 offline web applications

Saturday, April 4th, 2009

HTML 5 provides a new caching feature to support offline web applications.

Basically, you can specify in a specific file called the “cache manifest” the caching policy to apply to a particular web page.

To activate the HTML 5 caching feature for a specific document, you only need to specify the URI of the cache manifest file in the manifest attribute of the <html> element.

<!DOCTYPE HTML>
<html manifest="myapp.cache">
...

The file that references the cache manifest file is called the master entry.

Please note that to be properly parsed by the browser, the manifest file must have a text/cache-manifest MIME type (which means that you will need either to add a custom file type extension binding to your web server or to specify manually the mime-type, for instance using PHP header directive).

A cache manifest file typically looks like this:

CACHE MANIFEST
index.html
style.css
images/logo.png

NETWORK:
search.php

This file specifies several files to cache (the cache explicit entries), and then specifies that search.php should never be cached (it is said to belong to the online white list), so that any attempt to access that file will bypass the cache.

Whenever the user browses to the page corresponding to a document to which a cache manifest is associated, the browser must check on the server if the latter has been modified:

  • If it hasn’t, then the cached content is used,
  • If a new version of the cache manifest exists, then the cached content is considered as staled and reloaded from the server.

The cache manifest for a document may also contain fallback entries that can be used if the browser can’t retrieve the original content. Below is an example where a static image is used when the retrieval of a dynamically generated image fails:

CACHE MANIFEST
FALLBACK:
images/mirror-effect.php server-busy.jpg

HTML 5 also defines an application cache API to manually trigger cache updates:

  • update(): updates the cache for the current document in the background,
  • swapCache(): reflow the HTML document using updated cached content,
  • onupdateready(): event triggered when the cache content has been updated,
  • onobsolete(): event triggered when the cache content has been marked as obsolete,

HTML 5 <audio> & <video> elements

Friday, April 3rd, 2009

One of the most revolutionary concept introduced by HTML 5 is the native support of audio and video playback in web pages.

Two new HTML elements have been defined for that purpose: <audio> and <video>, based on the generic media element type.

Media elements use a common set of attributes:

  • src: defines the source of the media to render,
  • autoplay: boolean to activate|prevent immediate playback,
  • loop: boolean to activate|prevent automatic looping on content,
  • controls: boolean to display|hide browser playback user interface.

<video> and <audio> elements can contain elements to be displayed to the user in older browsers that do not support these new elements.

Below is an example of how to use the <audio> element:

<audio src="audio.ogv" controls width="100" height="50">
    <a href="audio.ogv">Listen</a>
</audio>

Alternatively to the src attribute, the content to be rendered can be specified using one or more <source> elements, each of them describing a specific media resource.

Each <source> can be identified by its src and type attributes, optionally complemented by a codecs attribute:

<audio controls width="100" height="50">
     <source src="audio.ogg" type="audio/ogg; codecs=vorbis">
    <source src="audio.spx" type="audio/ogg; codecs=speex">
    <source src="audio.oga" type="audio/ogg; codecs=flac">
</audio>

The <video> element has an optional poster attribute that can be used to define an image to be displayed before the video is played:

<video src="oggy.ogv" poster="oggy.jpg" />

These new media elements also support a set of handy javascript method, properties and events, to allow the fine-grained control of the rendered UI.

<script>
function playVideo(url){
     var video = document.getElementById("video");
     video.setAttribute("src",url);
}
</script>
<video id="videoPlayer" controls=false/>
<p>
     <button type="button"
             onclick="video.playbackRate = -2;">
         Rew
     </button>
     <button type="button"
             onclick="video.play();">
         Play
     </button>
     <button type="button"
             onclick="video.pause();">
         Pause
     </button>
     <button type="button"
                 onclick="video.playbackRate = 2;">
         FF
     </button>
</p>

New HTML 5 block-level elements

Monday, March 9th, 2009

The HTML 5 specification introduces new block elements that can be used to structure documents:

  • <section>: represents a document or application section (a content column for instance),
  • <article>: represents an independent piece of content inside a document/section (a blog entry for instance),
  • <aside>: represents a piece of content not directly related to the displayed content (typically a sidebar),
  • <header>: represents a document header,
  • <footer>: represents a document footer,
  • <nav>: represents a block of navigation links (typically a blog navigation bar),
  • <dialog>: can be used to render a chat session, using complementary <dt> (talker) and <dd> (quote) tags,
  • <figure>: can be used to provide textual information about an embedded content,
  • <address>: represents a document/section contact block,

download free edition adobe photoshopfree download hustler magazine in adobe format Kopen oem software download adobe after effectsadobe svg veiwer downloaddownload adobe acrobat for freeppd download adobe Windows 7 adobe flash player active x downloadadobe reader kostenloser download download Adobe software