testCSV = function(){
var csvData = "";
db.transaction(function(tx){
tx.executeSql('SELECT * FROM grocery', [], function (tx, results){
var len = results.rows.length, i;
for (i = 1; i < len; i++) {
csvData += results.rows.item(i).itemno + "," + results.rows.item(i).quantity + "\n";
}
window.location='data:text/csv;charset=utf8,' + encodeURIComponent(csvData);
});
});
};
当我在移动设备上运行相同的代码时,它会打开并在浏览器中显示csv文本。如何让它下载文件并在本地保存。有什么想法吗?