问题
I am working on cordova based hybrid application targeted to Windows 8.1 platform with InAppBrowser plugin added. I have used following code to open local image/pdf file:
window.open("Screenshot.png", "_blank", "location=no");
But it does nothing...no exception and no image.
I am able to use the same code to open text file. But the same code does not work with image/pdf/word/excel documents.
Any help will be much appreciated.
Thanks, Chirag.
Update: I found solution. Following is the sample code:
var applicationData = Windows.Storage.ApplicationData.current;
var localFolder = applicationData.localFolder;
console.log(localFolder);
var imageFile = "image.png";
// Get the image file from the package's image directory
localFolder.getFileAsync(imageFile).then(
function (file) {
console.log("1");
// Set the show picker option
var options = new Windows.System.LauncherOptions();
options.displayApplicationPicker = true;
// Launch the retrieved file using the selected app
Windows.System.Launcher.launchFileAsync(file, options).then(
function (success) {
if (success) {
// File launched
console.log("2");
} else {
// File launch failed
console.log("3");
}
});
});
Hope this helps someone.
Thanks.
来源:https://stackoverflow.com/questions/32935380/window-open-to-open-local-image-pdf-on-windows-platform-using-inappbrowser