开发者

Loading local files via jQuery (part 2)

开发者 https://www.devze.com 2023-04-11 14:41 出处:网络
Ok, here we discussed the essence of the problem: in some browsers like Chrome and Opera HttpRequests to local files is turned off by default.

Ok, here we discussed the essence of the problem: in some browsers like Chrome and Opera HttpRequests to local files is turned off by default.

Now the question is: how to build such HTML+java开发者_Go百科script viewer of HTML documents, that:

  1. would run locally on any (or most of) browser(s) without additional tuning;

  2. would not use frames;

  3. would have an ability to work with many different files(5-10k);


It can't be done in straight HTML/Javascript if you want to load files via Javascript using AJAX requests. There are good security reasons to not allow local files script access to other files on the local system (see my answer here for more details), so most browsers will not allow this without special user configuration.

So your options are:

  • Don't load files with Javascript, use frames or another mechanism. If, as you state in the other question, you're shipping all this on CD, you might want to consider using some sort of build system that allows you to create static files using templates and either a database or flat-file content - Jekyll is one option I know of.

  • Ship an executable along with the files that can either run a local webserver or run HTML files in an application context. I think Appcelerator Titanium might fit the bill.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号