DIV CSS 佈局教程網

您现在的位置: DIV+CSS佈局教程網 >> 網頁腳本 >  >> HTML基礎知識 >> HTML5詳解
Webkit 率先實作 HTML5 客戶端資料庫儲存
編輯:HTML5詳解     

目前正在規劃中的 HTML5 標準裡有許多令人振奮的特性,我們非常期待能將它們在 Webkit 中逐一實作。其中有一項特性,我們認為足以為瀏覽器帶來驚喜——儘管它甚至還未成為正式規範,那就是客戶端資料庫儲存。因此最近幾週,我和 andersca、xenon 一起完成了它的實作!

客戶端資料庫儲存介面允許網頁應用透過 SQL——一種許多 Web 開發者早已熟悉的媒介——來儲存結構化的本機資料。

這些介面是非同步的,並使用回呼函式來處理資料庫查詢的結果。以下是一個定義簡易回呼函式的範例:

var database = openDatabase("Database Name", "Database Version");

database.executeSql("SELECT * FROM test", function(result1) {
   // 對結果進行處理
   database.executeSql("DROP TABLE test", function(result2) {
     // 進行更多操作
     alert("My second database query finished executing!");
   });
});

我們也準備了一個在真實情境中如何使用這些介面的範例,並會持續隨進度更新。

這個初步的功能實作存在一些與規範不符的已知缺陷。不過它已經具備了基本能力,而讓人們真正把這個特性用起來,也正是探索後續工作需求的最佳方式!

原文:WebKit Does Html5 Client-side Database Storage
Posted by Brady Eidson on Friday, October 19th, 2007 at 4:04 pm

The current working spec for the Html5 standard has a lot of exciting features we would eventually like to implement in WebKit. One feature we felt was exciting enough to tackle now even though the spec is still in flux is client-side database storage. So for the last few weeks andersca, xenon, and I have been cooking up an implementation!

The client-side database storage API allows web applications to store structured data locally using a medium many web developers are already familiar with – SQL.

The API is asynchronous and uses callback functions to track the results of a database query. Compact usage defining a callback function on the fly might look something like this:

var database = openDatabase("Database Name", "Database Version");

database.executeSql("SELECT * FROM test", function(result1) {
   // do something with the results
   database.executeSql("DROP TABLE test", function(result2) {
     // do some more stuff
     alert("My second database query finished executing!");
   });
});

There will also be a small example of how to use the API in a real site that we'll try to keep up to date as things evolve.

This initial implementation has some things missing from the spec as well as a few known bugs. But it does the basics and the best way to discover what needs work is to get it out there for people to start using it!

If you find any bugs, would like to suggest features, or have gripes about the spec itself, please drop by #webkit or drop us a line on the WebKit email lists.

Oh, and one more thing…

We're landing this initial implementation with pretty cool Web Inspector support! So far you can view the full contents of any table and run arbitrary queries on each database a page is using. We have a lot of ideas for improvements but would also love to hear yours.

XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved