There's a static page myapp/page.html
and a static file in same directory myapp/data.txt
. I would like to open that page in Browser from the file system, without web server, and get content of the myapp/data.txt
file. It should be possible periodically reload that file to check if its content changed.
fetch('file:///myapp/data.txt')
is not working because of some security errorFetch API cannot load file:///myapp/data.txt
- Loading as an image
img.src='data.txt'
also not working, it loads the file it could be seen in the networking tab, but when you try to read it as the image content it tells that image is broken.
As a last resort it's possible to change data.txt
into data.js
and load it via script.src='data.js'
but maybe it's somehow possible to load it as a text too?