I am attempting to open a local folder by setting window.location.href
to file://folder/
, which I can do in IE, cannot in Chrome.
My goal is to catch
whenever a browser blocks local file access so I can call some other code. Chrome's console is showing me 'Not allowed to load local resource:...' but I am not able to catch it with a try/catch
block
Attempt:
function OpenLocalResource() {
try {
//Fails in Chrome (expected)
window.location.href = 'file://folder/whatever/';
} catch (err) {
//Chrome gives script error 'Not allowed to load local resource:'
//I am expecting to hit this catch block but it does not
alert("Error hit!");
}
}
OpenLocalResource();
How can I detect when a browser does not allow local resource access?
It's a security setting, I don't think you can catch it. But you could start chrome using the cmd prompt and adding --allow-file-access.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With