您的位置:首页 > Web前端 > HTML5

html5 web database

2016-03-19 21:13 441 查看
html5 web database

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script type="text/javascript">
var db=window.openDatabase('test','1.0','a',20000);
//数据库名  版本     大小
/*  if(db){
alert('数据库创建成功');
}*/
//    建表
/*    db.transaction(function (tx) {
tx.executeSql("create table tt(id int,name varchar)");
});*/
//    插入
/*    db.transaction(function (tx) {
tx.executeSql("insert into tt(id,name) values (3,'xiao')");
});*/
//    删除
/* db.transaction(function (tx) {
tx.executeSql("delete from tt where id=1");
});*/
db.transaction(function (tx) {
tx.executeSql("select * from tt",[], function (tx,rs) {
for(var i=0;i<rs.rows.length;i++){
document.write(rs.rows.item(i)['name']+'<br/>');
}
});
});
</script>
</head>
<body>

</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: