I know there is the origin problem, but setting up a web server is not an option here. Firefox v14 has no problem loading a local file. Chrome has no problem after adding '--allow-file-access-from-files' Is there any way to fix also IE9? Thank you
Edit: I figured out the solution. Just use ActiveXObject("MSXML2.XMLHTTP.6.0") instead of XMLHttpRequest() for IE9 to overe the local file access deny problem.
I know there is the origin problem, but setting up a web server is not an option here. Firefox v14 has no problem loading a local file. Chrome has no problem after adding '--allow-file-access-from-files' Is there any way to fix also IE9? Thank you
Edit: I figured out the solution. Just use ActiveXObject("MSXML2.XMLHTTP.6.0") instead of XMLHttpRequest() for IE9 to overe the local file access deny problem.
Share Improve this question edited Aug 13, 2012 at 9:50 hippietrail 17k21 gold badges109 silver badges179 bronze badges asked Aug 10, 2012 at 7:18 user1589188user1589188 5,73621 gold badges77 silver badges153 bronze badges3 Answers
Reset to default 4Ajax or not. HTTP is a client-server application protocol. Without a server, that's just not possible.
UPDATE:
Possible in chrome (and firefox) apparently. As for IE you can read up on Mark of the Web.
So far as I know,
Considering security issues, javascript had better not access local files. So it can't be standard.
In AJAX, there are respective ways to accessing local files for respective browsers.
For IE, as you seem to already know, while declaring an AJAX object initially, you should use
new ActiveXObject()
instead.The AJAX of the JavaScript library JQuery allow you to access local files. I think it implemented all the ways for different browsers, e.g., ActiveXObject for IE. AJAX of JQuery is very easy to use; everyone likes it. But as mentioned above, there are security problems. Since JQuery wrapped it all, JQuery may be dangerous for who visit you site.
===================================================================
ref: http://jquery.tiddlywiki/twFile.html (tell you the ways JQuery implementing access to local files)
In case you're using requirejs's text plugin, all you have to do is add this to the first require.config argument:
requirejs.config({
config: {
text: {
createXhr: function(){
return new ActiveXObject("MSXML2.XMLHTTP.6.0");
}
}
}
});
Maybe other JS libs use a similar syntax. Food for thought.