I need to write a software that uses HTML5 and canvas.
The whole software should be able to run locally, without the need of a server. So I'm only able to use Javascript, no php.
The difficult part: I have to dynamically fetch the content of text-files which are needed during operation.
For example: When the software starts, I need the "config.json". And after the user made some desicions, I need "story1.txt" or "story2.txt" and so on.
My Problem:
I can't use Ajax, because Chrome blocks it - local Files aren't allowed to fetch other files' content. I always get an error-Message.
What I've tried so far:
Load Files with Ajax & jQuery
Chrome doesn't allow me to load the file
Load File into script-Tag
Even if I declare the JSON-File as js-Code, I can't access the content of the loaded File
Load File into invisible Iframe, and read its content
Loading works, and I can see the code. But when I try to access the IFrame's content, I get the Chrome Error-Message again:
"Uncaught SecurityError: Blocked a frame with origin "null" from accessing a frame with origin "null". Protocols, domains, and ports must match."
Question:
Is there a way to load a Textfile dynamically, or am I forced to use a Webserver?
c:/cccc.txt
will give cross browser error.Check this answer stackoverflow.com/a/19866904/1671639--disable-web-security
flag - which isn't good if you are developing a commercial product.