Book Image

HTML5 Mobile Development Cookbook

By : Shi Chuan
Book Image

HTML5 Mobile Development Cookbook

By: Shi Chuan

Overview of this book

<p>How do I create fast and responsive mobile websites that work across a range of platforms? For developers dealing with the proliferation of mobile devices each with unique screen sizes and performance limitations, it is an important question. This cookbook provides the answer. You will learn how to apply the latest HTML5 mobile web features effectively across a range of mobile devices. <br /><br />HTML5 Mobile Development Cookbook will show you how to plan, build, debug and optimize mobile websites. Apply the latest HTML5 features that are best for mobile, while discovering emerging mobile web features to integrate in your mobile sites.<br /><br />Build a rock-solid default mobile HTML template and understand mobile user interaction. Make your site fast and responsive, leveraging the uniqueness of location-based mobile features and mobile rich media. Make your mobile website perfect using debugging, performance optimization and server-side tuning. The book finishes with a sneak preview of future mobile web technologies.</p>
Table of Contents (16 chapters)
HTML5 Mobile Development Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface

Using ECMAScript 5 methods


Target browsers: iOS 5

ECMAScript 5 is replacing ECMAScript 3.1. ECMAScript 5 provides a great enhancement to object interaction. Starting with iOS 4, Safari introduced many new ECMAScript 5 features; iOS 5 brought even greater support for ECMAScript 5.

The following are the newly introduced Object methods:

Object.seal/Object.isSealed
Object.freeze/Object.isFrozen
Object.preventExtensions/Object.isExtensible
Function.prototype.bind

Getting ready

Create an HTML document and name it ch10r02.html.

How to do it...

Enter the following code and test it in the browser:

/*** freeze ***/
var dog = {
eat: function () {},
hair: "black"
};
var o = Object.freeze(dog);
// test if dog is frozen
assert(Object.isFrozen(dog) === true);
// can't alter the property
dog.hair = "yellow";
// can't remove property
delete dog.hair;
// can't add new property
dog.height = "0.5m";
/*** seal ***/
var human = {
eat: function () {},
hair: "black"
};
human.hair = "blonde";
var o = Object.seal...