Translate

2 Aralık 2016 Cuma

Cordova / Ionic - Download file from InAppBrowser




1) install cordova plugin

    $ cordova plugin add cordova-plugin-inappbrowser
2) Add window.open for default /  add cordova.InAppBrowser.open for cordova appliation

If you want to open inside of app 

//for web browser

var ref = window.open('http://apache.org', '_blank', 'location=yes');
//for mobile app (cordova library)

cordova.InAppBrowser.open('http://apache.org', '_blank', 'location=yes')

If you want to open another browser (it will ask you to choose browser options)

var ref = window.open('http://apache.org', '_system', 'location=yes');
cordova.InAppBrowser.open('http://apache.org', '_system', 'location=yes') 




// If cordova library exist !!!!

if (window.cordova) {    
    ionic.Platform.ready(function(){
       cordova.InAppBrowser.open(item.url , '_system', 'location=yes')
       // if you want to use 
   })
 }else {

// 

   var link = document.createElement("a");
   link.download = item.name;
   link.href = item.url;
   if (window.webkitURL === undefined || window.webkitURL === null) {
     document.body.appendChild(link);
   };
   link.click();
 }


you can find detail in  HERE






Hiç yorum yok:

Yorum Gönder

Bu Blogda Ara