我正在开发一个应用程序,我想下载csv文件,它在我的PC上工作(chrome)但是因为我创建了.apk并通过移动设备进行了测试,但它没有下载任何文件,为什么会发生这种情况可以告诉我。 ...? 我的HTML代码是
<p id="today" style="display:block">
<a href="" id="todaydataLink" download="my_Data.csv" data-ajax="false"></a>
<a href="javascript:alert('test');" id="testLink"></a>
<b>Download Details</br></b>
From Date:<input type="date" id="startDate" name="startDate" placeholder="From Date"/>
<div id="errordt1" style="color:#f00">
</div>
To Date:<input type="date" id="endDate" name="endDate" placeholder="From Date"/>
<div id="errordt2" style="color:#f00">
</div>
<button id="todayLink" >Download</button>
</p>
And jquery code is
<script>
/************************Download CSV File- ***************************/
var $link = $("#todaydataLink");
console.clear();
$("#todayLink").click(function (e) {
var startDate='';
var endDate='';
var csv = "";
var num='';
var var4='';
var inamnt=0;
var dispdt='';
startDate=document.getElementById("startDate").value;
endDate=document.getElementById("endDate").value;
if(startDate=='')
{
$("#errordt1").text("Please Enter From Date").show();
return false;
}
if(endDate=='')
{
$("#errordt2").text("Please Enter To Date").show();
return false;
}
$("#errordt1").text("").show();
$("#errordt2").text("").show();
db.transaction(function(t) {
t.executeSql(
'select * from U_Ine_Ex UIE, categories cat where UIE.Flag=1 and UIE.Category=cat.cat_id and UIE.DOE BETWEEN "' +startDate+ '" AND "' +endDate+ '" order by id desc',
[],
function (t, results) {
var len_curr = results.rows.length;
for(var i=0;i<len_curr;i++)
{
num=results.rows.item(i).name;
var datadate=results.rows.item(i).DOE;
dispdt=datadate.split('-');
var4=dispdt[2]+'-'+dispdt[1]+'-'+dispdt[0];
inamnt=results.rows.item(i).Amount;
csv += num + "," + var4 + "," + inamnt + "\n";
}
console.log(csv);
$link.attr("href", 'data:Application/octet-stream,' + encodeURIComponent(csv))[0].click();
});
});
});
/************************Download CSV File- Ends Here***************************/
</script>