2012-01-25 108 views
1

我們已經構建了一個Phonegap/Android應用程序,該應用程序使用iframe處理付款併爲mp3提供下載鏈接 - 所有工作正常 - 直到您單擊下載並且什麼也沒有發生!Phonegap Android鏈接 - 下載鏈接

在應用程序中是否存在iframe下載權限問題?有沒有人有任何想法如何解決?

感謝 保羅

+0

目標=「_父」關於在iframe的所有鏈接屬性作爲解決方法..作爲一種解決方法..不理想,因爲它需要在應用程序外的用戶下載... – Dancer

回答

1

兩個可能的解決方案:

// 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的鏈接。

或使用jQuery您的iFrame中(前提是有隻1中的iFrame鏈接),這將打開應用程序的外部鏈接:

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