简体   繁体   中英

Download File Link for In App Browser

A mobile app having an In App browser links to website to download files.

I added the download attribute to force download

<a android:linksClickable="true" href="'.$url.'/used/'.$productcode.'" target="_blank" alt="Order" title="Order #'.$orderid.'" download>Download Key</a>

It's working on desktops allowing you to download the file however when clicking the link in the mobile app it does nothing.

I also added the javascript in header maybe it resolve the issue but it is still not working

   <script type="text/javascript">  
        function externalLinks() {
            var links = document.querySelectorAll("a"),
                i = 0,
                len = links.length;
            for (; i < len; i++) {
                (function(link, j) {
                    if (link.href) {
                        link.target = "_blank";
                        alert("index = " + j);
                        link.addEventListener("click", function() {
                            alert(j);
                        }, false);
                    }
                }(links[i], i));
            }
        }
    </script>

In our XML file for the link you can add

android:autoLink="web"

and the link should be clickable and work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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