Closed robertok-weiji closed 3 years ago
@robertok-weiji Can you provide a sample code of requesting the resource from Library path in your application?
Yes, i've created a simple helloworld project with cordova 10.0.0
cordova create helloworld
I'm using the cordova-plugin-file in order to write the sample iframe source to the sandbox.
cordova plugin add cordova-plugin-file
In the index.js sample file, i've added this to the onDeviceReady function, to dynamically add an iframe pointing to dataDirectory:
` function onDeviceReady() {
console.log('Running cordova-' + cordova.platformId + '@' + cordova.version);
document.getElementById('deviceready').classList.add('ready');
window.resolveLocalFileSystemURL(cordova.file.dataDirectory, function (fs) {
fs.getFile("iframe.html", { create: true } , function(fileEntry) {
fileEntry.createWriter(function(writer) {
writer.onerror = function(evt) {
alert(JSON.stringify(evt))
}
writer.onwrite = function(evt) {
var iframe = document.createElement('iframe');
iframe.src = fileEntry.nativeURL;
iframe.width = "30%"
iframe.height = "30%"
document.body.appendChild(iframe);
alert("Appended iframe with src " + iframe.src)
}
writer.write("<html><head></head><body style='background-color:red'><h1>TEXT INSIDE IFRAME, IT WORKS!</h1></body></html>");
}, function(err) {alert("HTML error writing file: "+ JSON.stringify(err)); });
}, function(err) {alert("HTML error getting file: "+ JSON.stringify(err)); });
});
} `
I've tried this on platform ios@5.1.1 (old UIWebView), it perfectly works.
I've tried on ios@6.1.1 (WKWebView) with and without the cordova-plugin-wkwebview-file-xhr@3.0.0 plugin, it doesn't work ("WebPageProxy::Ignoring request to load this main resource because it is outside the sandbox")
I've also tried with ios@5.1.1 using cordova-plugin-wkwebview-engine@1.2.1 and cordova-plugin-wkwebview-file-xhr@3.0.0, same result, it doesn't load the iframe.
Thanks in advance.
Hi @manish2788 , have you got to check this? Thanks.
Thanks @robertok-weiji for sharing let us verify and get back to you.
@robertok-weiji Is this the place where you are facing issue in fetching iframe.html
fs.getFile("iframe.html"
Sorry @manish2788 , I don't understand, what is the problem in this statement? Thanks.
@robertok-weiji You can see in description on how to use XMLHTTPRequest "GET" method to read local file from device.
@manish2788 sorry, it was opened for more than three months without a solution. Why now is it closed? The problem persist...
As stated in the plugin description "the plugin verifies that the standardized path of the target URL is within the "www" folder of the application's main bundle or in the /Library path of the application data directory.". I'm trying to load in