《Pro HTML5 Programming》Web Storage[1]

 

HTML5 网络存储API

 

        在这章,我们将会学习到HTML5的具体应用——有些时候也被称作DOM存储,一种能在网络请求的过程中能够更容易的保存数据的API。

 

网络存储API,前身就是可爱的cookie.以一种在程序间传递少量数据数值的古老程序(Programing)技术命名,也叫做magic-cookie——在用户和服务器之间来回不断地传递数值的嵌入式方法。服务器可以记录用户信息并跟踪用户在浏览过程中的数据。Cookie中可以存储用户的ID以便在诸如购物网站之中存储是哪个用户买了这件商品。Cookie的另一种用途便是在本地应用中存储数值,以便那些数值可以在后继的页面载入中也能够被调用。

 

Cookie值还应用于某些不那么和人心意的操作中,比如为了广告之类的信息而跟踪用户访问过的页面的操作。同样的(As such),用户也强烈要求浏览器提供随时随地消除Cookie的权利和功能。

 

除了Cookie的普遍特性之外,当然也有一些不尽如人意的地方:

 

1.Cookies严格受大小限制。一般来说只有4KB的数据可以被存储在一个cookie里,意味着大型数据比如文档或者邮件神马的就不可能被存进去了。

        2.Cookie总是在服务器和客户端之间来回往复,不仅仅意味着cookie资料对于客户来说是可见的,还意味着当cookie没有加密的时候是有安全隐患的。而且任何以cookie形式保存的数据在每次联网的时候都会占用带宽。现在,cookie精巧的量级有更大的意义。

 

很多情况下,不用引入网络或是远程服务器是可以达到某种特定的效果的。通过使用HTML5,开发者可以将JavaScript对象缓存在页面加载中(page loads)..(?)通过使用SessionStorage 或者 LocalStorage,开发者可以选择让数据或者存储在单独窗口的页面载入,或者存储在浏览器重启的过程中(?)。这些数据不会被传送到网路上,以便之后能

够更快更有效地调用。还有,应用此API可以存储更大的数据集,可以到几兆,以适应了那些超过文件大小限制的文件数据。

 

Web Storage浏览器支持 Chrome3.0之后,Firefox 3.0之后,IE 8.0之后,Opera10.5之后,Safari 4.0之后。 使用Web Storage API Web Storage很容易使用,我们将会从简单的存储和检索做起,进而比较两种存储方式的异同。最后我们将研究API更NB的方面,比如当变量值改变时候的事件提醒。

    检查浏览器支持状况

 

 

 

很多浏览器并不支持与文件系统直接联系的文件的sessionStorage存储方式。 注:我们已然可以使用的API有很多很多,但是浏览器可能只支持其中的某一部分。然而,因为Web Storage API 体积很小,已经在很多浏览器中能够做到一致的用户体验。考虑到也可能是用户处于安全和以防泄密的考虑从而关闭了那些实际上能够提供Web Storage 功能的网页的此选项。

 

 

 

......

因为Imagine Cup WP7要求做出一个应用程序,在3月7日之前提交一份项目描述。我所在的由四个人组成的 One Thousand 小组现阶段所确立的研究方向是 基于HTML5 Offline Storage 技术的Web应用程序,其所处的系统平台是微软的Windows Phone 7平台,我们这个囧啊,关于此项目的难点神马的我可以单独发一篇博客去讲,咦?发篇博客去讲讲?也许就能得到好心人的帮助了呢~哈哈,想想而已,但确实觉得如果那样做了的话就能把思路捋清楚一点了。会不会泄露了小组机密?问问组长去。

 

        这篇博客是我在看Q群里乐于分享的朋友上传的《Pro HTML5 Programming》的英文版pdf时候做的翻译,由于水平有限,仅仅做参考,主要是我为自己的学习过程做个记录,有谁看见了,觉得翻译的不好也是应该的。

 

我想说的是,学习一门新东西真的很不容易。聪明的还好,自己创造东西让别人学,像我这样比较笨的...就杯具的只能捡前人剩下的。开端而已,继续努力。

Book Description HTML5 is here, and with it, rich Internet applications (RIAs) take on a power, ease, scalability, and responsiveness that neither Ajax nor Comet could ever achieve. With this book, developers will learn how to use the latest cutting-edge web technology—available in the most recent versions of modern browsers—to build real-time web applications with unparalleled functionality, speed, and responsiveness. The HTML5 specification represents the next evolution—or rather, a revolution—of web communications required to build real-time applications. WebSockets and server-sent events provide not only a standard against which real-time web applications can be built, but also a socket, native to the browser, that facilitates network programming from the browser with efficient bidirectional (full-duplex) communication over a single connection. * Explains how you can create real-time HTML5 applications that tap the full potential of modern browsers * Provides practical, real-world examples of HTML5 features in action * Shows which HTML5 features are supported in current browsers and platforms What you’ll learn * How the HTML5 specification has evolved * How to design, develop, and run cutting-edge real-time web applications using new HTML5 features like WebSockets, server-sent events, cross-document messaging, geo location, storage, canvas, and video * Which features are available in browsers today and how you can run your applications in older browsers that do not support HTML5 features * How to use client-side APIs to communicate directly with back-end systems such as messaging systems, JMS brokers, XMPP servers, and online services such as Google Wave Who is this book for? This book is for developers who want to use the latest cutting-edge technology available in current browsers; developers who want to create dynamic, data-driven web applications; and developers who want to know which HTML5 features are supported in current browsers. About the Author Peter Lubbers is the Director of Documentation and Training at Kaazing Corporation, where he oversees all aspects of documentation and training. Peter also teaches a three-day HTML5 training course for Skills Matter. Prior to joining Kaazing, Peter worked as an information architect at Oracle, where he wrote many books, including the award-winning Oracle Application Server Portal Configuration Guide. At Oracle, Peter also developed documentation automation solutions and two of his inventions are patented. A native of the Netherlands, Peter served as a Special Forces commando in the Royal Dutch Green Berets. Peter lives on the edge of the Tahoe National Forest and in his spare time, he loves to run in the Sierra Nevada foothills and around Lake Tahoe (preferably in one go!). Brian Albers is the VP of development at Kaazing. Brian has over 13 years of experience in the field of User Interface technologies. Prior to joining Kaazing, Brian worked as Senior Development Manager at Oracle, where he led the planning and designing of the next generation of Oracle's UI technology—an effort publicly known as ADF Faces. During his 10 year tenure at Oracle, Brian worked primarily on mixing cutting-edge technology with large enterprise demands (internationalization, accessibility, scalability). He proposed the open source donation of ADF Faces, which ultimately became the Apache MyFaces Trinidad project. Brian also led a cross-team effort to develop a DHTML rich client and a mobile client presentation layer for Oracle's Project Fusion. Brian received a BS degree in Computer Science from the University of Texas, Austin, and a BA degree in Plan II Honors from the University of Texas, Austin. Frank Salim is a polyglot programmer with a keen interest in making life easier for his fellow coders. Frank leads WebSocket development at Kaazing. He is an open source advocate and a committer in several open source projects. Ric Smith is director of Oracle’s Fusion Middleware E20 Architect Team. Formerly, he led business and product strategy at Kaazing. Ric has also held various roles in product management, consulting, and software engineering. In addition, Ric is a frequent speaker at international events and has written articles featured in leading industry publications such as Java Developer's Journal and AJAX World Magazine.
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值