Phonegap Android链接-下载链接

Phonegap Android链接-下载链接,android,jquery-mobile,cordova,Android,Jquery Mobile,Cordova,我们已经建立了一个Phonegap/Android应用程序,它使用iframe来处理付款,并为mp3提供下载链接——一切正常——直到你点击下载,什么都没有发生 应用程序中的iframe下载权限是否存在问题?有人知道怎么解决吗 谢谢 保罗两种可能的解决方案: // Make sure links in the webview is handled by the webview and not sent to a full browser myWebView.setDownloadL

我们已经建立了一个Phonegap/Android应用程序,它使用iframe来处理付款,并为mp3提供下载链接——一切正常——直到你点击下载,什么都没有发生

应用程序中的iframe下载权限是否存在问题?有人知道怎么解决吗

谢谢
保罗

两种可能的解决方案:

    // 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);
        }
    });
它可以打开与您的WebView的链接

或者在iFrame内部使用jQuery(前提是iFrame中只有一个链接),它将打开应用程序外部的链接:

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

$(文档).ready(函数(){
var-url;
url=$(“a”).attr('href');
$(“a”).attr(“onclick”、“window.open”(“+url+”);返回false;”);
});

两种可能的解决方案:

    // 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);
        }
    });
它可以打开与您的WebView的链接

或者在iFrame内部使用jQuery(前提是iFrame中只有一个链接),它将打开应用程序外部的链接:

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

$(文档).ready(函数(){
var-url;
url=$(“a”).attr('href');
$(“a”).attr(“onclick”、“window.open”(“+url+”);返回false;”);
});
iframe中所有链接上的target=“\u parent”属性可以作为一种变通方法。。但这并不理想,因为它需要应用程序之外的用户进行下载…顺便说一句,iframe中所有链接上的target=“\u parent”属性可以作为一种解决方法。。但并不理想,因为它需要应用程序外的用户下载。。。