When I try my code out:
Testing.html -
The answer from @IsraelGav is correct in the sense that this problem occurs when the code is accessed from a local file but not when accessed from a web server. It is also correct in the sense that using the --allow-file-access-from-files
flag can allow the local file to be accessed by Chrome.
However, it misses an important security concern here. Both the concern, as well as an alternative possible solution, were originally described in this other SO answer by @orszaczky. To summarize the alternative solution: On Windows, install http-server (npm install -g http-server
) and run http-server
from your project directory. On Mac/Linux, run python -m SimpleHttpServer
from your local directory. You can now access the locally hosted web site in your browser. On Windows I had to use localhost:8080
while on the Mac I had to use localhost:8000
.
By the way, this is not only an issue for Chrome (v49.0) but also for Opera (v35.0), on both Windows and Mac.