简体   繁体   中英

Reading a local json file

I'm developing an offline "application", based on HTML5 . For my purpose I need to read a local json file but, as I experienced and as I read, through javascript this option is unavailable because of security policies.

Have you any idea about how to bypass the problem? Every hint is well accepted.

That's not entirely true.

Chrome has some security restrictions that prevent local JSON being read by default; however Firefox for example works fine out of the box.

There are some workarounds for Chrome , however the fixes usually rely on modifying settings on the clients machine.

If you want to create an "offline application" than why do you want to use webtools like a browser (and not JavaFX, Windows, ...).

You can say that you want to use the browser as a client for your purposes (or you are webdeveloper). Then you can use a local server to serve you "offline". Simple to start most of them not even to install or needed a large environment.

There are a plenty of local server and they are very powerfull to do anything you want. Search the web for web servers, languages or frameworks like: play framework, nodejs and many many more. After using such a server you can access any local service or local files.

This is how webdevelopers work on their local machines and transfering that to the target server afterwards.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM