简体   繁体   English

Phonegap Android链接-下载链接

[英]Phonegap Android link - Download link

We have built a Phonegap/Android app which uses an iframe to process payments and provide a download link for a mp3 - all works fine - until you click to download and nothing happens! 我们已经构建了一个Phonegap / Android应用程序,该应用程序使用iframe处理付款并提供mp3的下载链接-一切正常-直到您单击下载并没有任何反应!

Is there issues with iframe download permissions within an app? 应用程序中的iframe下载权限是否存在问题? Does anyone have any ideas how to solve? 有谁知道如何解决?

Thanks Paul 谢谢保罗

Two possible solutions: 两种可能的解决方案:

    // Make sure links in the webview is handled by the webview and not sent to a full browser
    myWebView.setDownloadListener(new DownloadListener() {
        public void onDownloadStart(String url, String userAgent,
                String contentDisposition, String mimetype,
                long contentLength) {
            Intent intent = new Intent(Intent.ACTION_VIEW);
            intent.setData(Uri.parse(url));
            startActivity(intent);
        }
    });

which could open the link with your WebView. 这可以打开您的WebView的链接。

or inside your iFrame with jQuery (provided there is only 1 link in the iFrame) which will open the link outside of the application: 或使用jQuery在iFrame内(如果iFrame中只有1个链接),则会在应用程序外部打开该链接:

<script type="text/javascript">
  $(document).ready(function() {
    var url;
    url = $("a").attr('href');
    $("a").attr("onclick", "window.open('"+url+"'); return false;");
  });
</script>

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

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