导出WebSQL数据 [英] Exporting WebSQL Data

查看:277
本文介绍了导出WebSQL数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

WebSQL的主要问题之一是它容易丢失数据.每次删除浏览器历史记录时,WebSQL表中存储的数据也会被删除.有什么方法可以仅使用Javascript来防止数据丢失,从而导出/下载WebSQL数据或将其写入文件?我知道您无法从JavaScript访问文件系统,所以这是否有可能?谢谢.

One of the major problems with WebSQL is its vulnerability to losing data. Every time the browser history is deleted so is the data stored in your WebSQL tables. Is there any way to export/download the WebSQL data or write it to a file, using only Javascript to prevent data loss? I know you can't access the file system from JavaScript so is this even possible to do? Thanks.

推荐答案

您可以将所有数据放入JavaScript变量,然后document.location到它.

You could get all the data into a JavaScript variable and then document.location to it.

HTML:

<a href="javascript:onDownload();">Download</a>

JavaScript:

JavaScript:

function onDownload() {
    document.location = 'data:Application/octet-stream,' +
                         encodeURIComponent(dataToDownload);
}

(摘自此博客文章: 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆