I would like to export a WebSQL database into a csv file locally on a mobile device using a webkit browser. Currently this code works inside google chrome and creates a file that automatically downloads:
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);
});
});
};
When I run the same code on the mobile device it opens and displays the csv text in the browser. How can I get it to download the file and save it locally. Any ideas?