我可以使用本地存储制作非托管 HTML5 应用程序吗?
我有一个 PHP/MySQL 网站,我正在考虑将其转换为可以在本地用户计算机上运行的 HTML5/JavaScript。我希望用户能够在没有网络连接的情况下下载我的网站、解压并使用它。该站点的静态镜像将有数百兆字节,而实际数据不到 10 兆字节。有没有办法提前预加载 HTML5 Web 存储?或者如果没有我的数据,我是否必须使用 JavaScript 来加载网络存储?有什么想法或指示吗?谢谢
I have a PHP/MySQL site I'm thinking about converting into a HTML5/JavaScript that could be run off of a users computer locally. I would like the user to be able to download my site, extract it and use it without a network connection. A static mirror of this site would hundreds of megabytes while the actual data is under 10 megabytes. Is there a way to preload the HTML5 web storage ahead of time? Or would I have to use JavaScript to load the web storage if doesn't have my data? Any ideas or pointers? Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我不太清楚你的意思,“这个网站的静态镜像将有数百兆字节,而实际数据不到 10 兆字节”,但我相信从 HTML5 存储读取/写入的唯一实用方法是通过 JavaScript,因此,当他们第一次运行您的应用程序时,必须检查数据是否存在于存储中,以及是否没有使用 JavaScript 从某些来源填充数据。除了据我所知,没有办法“预加载”它。
I'm not quite sure what you mean by, "A static mirror of this site would hundreds of megabytes while the actual data is under 10 megabytes," but I believe the only practical way to read/write from HTML5 storage is via JavaScript, so when they first run your app it would have to check to see if the data exists in storage, and if it's not populate it from some source using JavaScript. There's no way to "preload" it other than that AFAIK.
实际上,您需要 “离线 Web 应用程序” HTML5 的功能,以便在本地提供页面服务(即充当本地 Web 服务器)。
另一种在本地提供 Web 应用程序的方法是通过 CouchDB:可轻松安装在 Linux 上(不确定在 Windows 上),并提供集成的 Web 服务器,当然还有数据库。如果用户安装了扩展程序,您可以从浏览器将您的 HTML/JS 站点“推送”到 CouchDB(在 Firefox 和 Chrome 中可以轻松完成)。
Actually, you would need "Offline Web Applications" functionality of HTML5 in order to serve pages locally (i.e. act as a local Web Server).
Another way to serve Web applications locally can be through CouchDB: easily installable on Linux (not sure on Windows) and provides an integrated Web server with of course a database. You could "push" your HTML/JS site to CouchDB from a browser provided the user installs an extension (easily done in Firefox & Chrome).