I have a web page that serves as a configuration editor, which means that it will be accessed by opening the .html file and not using http.
This page needs to access to another file (the configuration file to be edited), located in the same directory. The file is accessed using a relative path General.json
.
var getJSONFileContent = function( url ) {
return $.ajax({
type: "GET",
url: url,
async: false
}).responseText;
};
var currentConfigAsJson = getJSONFileContent( "General.json" );
It works perfectly on Firefox, without changing settings or anything, but it fails on both IE and chrome.
Chrome error:
file:///C:/Users/XXX/Desktop/XXX/General.json.
Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https, chrome-extension-resource.m.ajaxTransport.send
@ jquery-1.11.3.min.js:5m.extend.ajax
@ jquery-1.11.3.min.js:5getJSONFileContent
@ General.html:68(anonymous function)
@ General.html:75m.Callbacks.j
@ jquery-1.11.3.min.js:2m.Callbacks.k.fireWith
@ jquery-1.11.3.min.js:2m.extend.ready
@ jquery-1.11.3.min.js:2J
@ jquery-1.11.3.min.js:2
Internet Explorer error:
SCRIPT5: Access denied.
Fichier : jsoneditor.min.js, line : 7, column : 8725
I read that this is forbidden on Chrome (and probably IE and others) for security reasons, and that I have to start chrome with special arguments to bypass this.
But why is it working on Firefox? Is there a way to make it work on Chrome without passing special arguments when running chrome ?
Are there Chrome specific features that would allow me to read/write files without having to change settings or pass arguments ? An-end user wouldn't want to bother with that.