<!DOCTYPE HTML PUBLIC
"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd"
>
<
html
>
<
head
>
<
meta
http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
>
<
title
>创建对象仓库
</
title
>
<
script
>
function
CreateaObjectStory()
{
var
dbName=
"indexedDBTest";
var
dbVersion=
3;
var
idb;
var
dbConnect=
indexedDB.
open(
dbName,
dbVersion);
dbConnect.
onsuccess=
function(
e){
idb=
e.
target.
result;
alert(
"数据库链接成功!";)
}
dbConnect.
onerror=
function(){
alert(
"数据库链接失败!";)
}
dbConnect.
onupgradeneeded=
function(
e){
idb=
e.
target.
result;
//开始创建数据仓库(数据表)
var
name=
"user";
//数据仓库表名
var
optionalParameters={
keyPath:
"userid",
autoIncrement:
false
};
//数据仓库表数据
var
store=
idb.
createObjectStore(
name,
optionalParameters);
alert(
"对象数据仓库创建成功!");
}
}
</
script
>
</
head
>
<
body
>
<
input
type=
"button"
value=
"创建数据仓库"
onclick=
"CreateaObjectStory();"
>
</
body
>
</
html
>