How to download files from external site inside Intel XDK app

How to download files from external site inside Intel XDK app

I'm working on Android app and I use Cordova on intel XDK.

I want to open external link with iframe and allow the user to download file from a link inside the website but when I click on download link inside this site, nothing really happens... 1. I am using iframe which opens site inside app but website contains some download links but when i click on those links they are not showing anything.

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

It sounds like your app consists of a wrapper for a website. In that case I recommend you use the InAppBrowser plugin rather than an iframe to open a new view of that website. It should behave more like a browser. You're app is not running inside a browser, it is running inside of a webview:

I use appin browser plugin and i use below code but it is still not working
var InAppBrowserRef = null;
var CheckLocalStorageInterval = null;

function onAppReady() {
if (navigator.splashscreen && navigator.splashscreen.hide) { // Cordova API detected
navigator.splashscreen.hide();
}

var InAppBrowserRef = cordova.InAppBrowser.open("http://kashmiruniversity.net", '_blank', 'location=yes');

InAppBrowserRef.addEventListener('loadstop', function (page) {
console.log('Loaded', page.url);

// clear any previous interval
if (CheckLocalStorageInterval) clearInterval(CheckLocalStorageInterval);

// just inject script when entering download page
".on('click.download',function (evt) {" +
"localStorage.setItem('download', evt.target.href);" +
"$(evt).preventDefault();" +
"});"
});

// Start an interval
var CheckLocalStorageInterval = setInterval(function () {

// Execute JavaScript to check for the existence of a name in the
// child browser's localStorage.
InAppBrowserRef.executeScript({
code: "localStorage.getItem( 'download' )"
},
function (values) {
if (!values || !values[0]) return;
var fileUrl = values[0];
console.log('User ask to download file', fileUrl);
}
);
}, 5000);
});
}
document.addEventListener("app.Ready", onAppReady, false);

Leave a Comment

Please sign in to add a comment. Not a member? Join today