可以通过Web应用程序离线访问本地文件? [英] can web offline app access local file?

查看:359
本文介绍了可以通过Web应用程序离线访问本地文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好:
  我在沃金创建离线Web应用程序。我希望它可以在一个UIWebView(IOS)或的WebView(Android版)上运行。我不知道,如果它的工作。 HTML和JavaScript文件,现在的工作很好,但我的应用程序需要处理这是我自己定义的一些二进制文件,而这些文件是动态创建的,因此不能放在离线缓存清单。如果网页是在Web浏览器从Web服务器下载,我可以通读XMLHtt prequest的二进制文件。但是,如果浏览器中打开的页​​面为本地文件,二进制文件无法通过http协议读取,甚至也不能由JavaScript访问,我想出于安全原因。我在这里stucked,你们可以给我关于JavaScript在离线Web应用程序如何创造一些技巧/读/写本地文件?我试图用< IMG SRC =my_data_file/> ,希望我可以得到从元件的原始数据,但没有办法。如果JavaScript不能做到这一点,有没有什么解决方法,使用已有的HTML标签读取原始数据?

Hi guys: I am woking on creating a offline-web application. I hope it can be run in UIWebView(iOS) or WebView(Android). I don't know if it does work. The html and javascript files work fine now, but my apps need to process some binary files which is defined by myself, and these files are dynamic created so they can not be put in off-line cache manifest. If the web pages are loaded in web browser from web server, I can read the binary files through XMLHttpRequest. But if the browser open the pages as local files, the binary files can not be read through http protocol and even can't be access by the javascript, I guess for security reasons. I am stucked here, could you guys give me some tips about how can javascript in off-line web app create/read/write local files? I tried to use <img src="my_data_file"/>, and hope I can get the raw data from the element, but no way. If the javascript can not do this, is there any workaround to use existed html tags to read the raw data?

推荐答案

有是本地存储,它就像一个数据库。这里有一个很好的教程。

There is local storage, and it works like a database. Here's a nice tutorial.

http://html5tutorial.net/tutorials/working-with-html5- localstorage.html

您必须动态地加载图像尽管使用Image()对象。浏览器应该缓存,虽然在离线模式下图片...

You'll have to load the images dynamically though using the Image() object. The browser should cache images in offline mode though...

这个问题看起来类似于pretty到你要找的是什么:

This question looks pretty similar to what you're looking for:

<一个href=\"http://stackoverflow.com/questions/4940586/can-you-use-html5-local-storage-to-store-a-file-if-not-how\">Can使用HTML5本地存储来存储文件?如果不是,怎么样?

这篇关于可以通过Web应用程序离线访问本地文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆