html5 web database

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>

 

posted @ 2016-03-19 21:13  gyz418  阅读(153)  评论(0)    收藏  举报