Ionic 3 The external links open only once in system browser outside in appbrowser

时间:2018-06-19 11:16:50

标签: ionic-framework ionic3 inappbrowser

i wrapped a website and there are external links which i made to open in System browser, but when I return to in-app browser using hardware back button and again try to open the external links it doesn’t open. It looks like the 'loadstart" occurs only once.Or am i doing anything wrong here?

home.ts

export class HomePage {
constructor(public navCtrl: NavController, private iab: InAppBrowser, public 
platform: Platform,private fileOpener: FileOpener, private 
transfer:FileTransfer, private file: File, private diagnostic:Diagnostic) {
platform.ready().then(() => {
const browser = 
this.iab.create('https://www.tutorialspoint.com/ionic/index.htm','_blank', 
{zoom:'yes',location:'no', clearcache: 'yes', clearsessioncache: 'yes'});
browser.show();
browser.on('loadstart').subscribe(
(data) => {
console.log("URL IS", data.url);
this.downloadfile(data.url)
},
err => {
console.log("InAppBrowser Loadstop Event Error: " + err);
}
);
});
}
downloadfile(url) {
var externalCheck = (!url.includes("tutorial.points"));
var pdfCheck = (url.substr(url.length - 4) == '.pdf');
if (externalCheck || pdfCheck) {
window.open(url, "_system", 'location=no');
}
}
}

Is there any solution for this ? any help is really appreciated.Thanks in advance

0 个答案:

没有答案