简体   繁体   English

使用jquery下载文件(apk)时出现问题

[英]Problems download file (apk) using jquery

I'm having problems when making a download apk from page in html, this happens with Andorid devices that use browser "Chrome". 从html页面下载apk时遇到问题,这种情况发生在使用浏览器“ Chrome”的Andorid设备上。

The problem is, when you click on the download link from browser chrome begins to cycle the page "n" number of times without finish downloading the file, I been attempted solved with HTML5 with sentences of download href "" download. 问题是,当您单击浏览器chrome的下载链接开始循环页面“ n”的次数而没有完成文件下载时,我试图使用HTML5来解决句子href为“ download”的问题。 Tests with jquery and a script that invokes the download was tested and finally make different statements within the simple HTML were also made. 使用jquery和调用下载的脚本进行了测试,并最终在简单的HTML中做出了不同的声明。

NOTE: THIS ONLY HAPPENS IN CHROME BROWSER IN OTHER BROWSERS LOW FILE NO PROBLEM. 注意:仅在其他浏览器中的铬浏览器中发生这种情况,低文件没有问题。

<meta charset="utf-8" />
<title>Prueba HTML5 SDK</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.css" />
<script src="http://code.jquery.com/jquery-1.11.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.5/jquery.mobile-1.4.5.min.js"></script>
<script>
    $(document).ready(function() {
        $("a").click(function(evento) {
            alert("Deseas descargar version de Android");

            < ul >

            < a href = "https://www.bancomermovil.net:11443/mbank/mbank/Descargas/BPromo/android/V62/SuiteBancomerBBVANow.apk" > Descargar! < /a>
         </ul >

try to generate a unique href for every click on the link element: 尝试为每次单击链接元素生成唯一的href:

$("a").click(function(evento) 
{
        evento.preventDefault();
        var href = $(this).attr('href') + '?' + Math.random();
        window.location.href = href;
});

this way chrom will not cache your request and treat every download like its the first 这样chrom不会缓存您的请求,并且不会像第一次下载那样对待每次下载

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM