html5存储:
1.localStorage,sessionStorage
2.WebSQL
3.inexedDB(key-value的数据库)

 

【代码】

<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <title>indexedDB测试</title>
    <script>
        window.onload = function () {
            var version = 1;

            var test = indexedDB.open('testDB',version);
            test.onerror = function (e) {
                document.getElementById('log').innerHTML = "连接失败";
            }

            test.onsuccess = function (e) {
                document.getElementById('log').innerHTML = "连接成功";
            }

            document.getElementById('update').onclick = up;
            function up() {
                document.getElementById('log').innerHTML = "数据库正在升级......";
                version = version + 1;
                var test = indexedDB.open('testDB',version);
                test.onupgradeneeded = function (e) {
                    var db = e.target.result;
                    var store = db.createObjectStore('Users', {keyPath: 'userId', autoIncrement: false});
                    document.getElementById('log').innerHTML = "数据库升级成功,当前版本号为:"+version;
                }
            }
        }
    </script>
</head>
<body>
<h1 id="log" style="text-align: center;color:red;"></h1>
<center>
    <input type="button" id="update" value="升级">
</center>
</body>
</html>