試圖實現HTML5的離線功能。做了大量的搜索之後,這就是我的代碼的外觀。 (這是一個Django項目;部署在APACHE2.2與mod_wsgi
插件)
HTML
`HTML5離線網絡應用程序不適用於Android 2.x,iPhone。 (但在Android 4.0中可用)
<!DOCTYPE HTML>
<html manifest="{{MEDIA_URL}}cache.manifest">
<head>
<meta charset="utf-8">
<title>MyHomeStuff</title>
<script type="text/javascript" src="{{MEDIA_URL}}MyHomeStuff.js" ></script>
<script></script>
</head>
<body>
.............
</body>
</html>
`
的Apache的conf \的mime.types
text/cache-manifest manifest
\ Python27 \ Lib \ mimetypes.py
新增'.manifest': 'text/cache-manifest',
爲types_map
字典
(通過上述除mimetypes.py,它開始爲Android 4.0的工作)
cache.manifest
CACHE MANIFEST
CACHE:
index.html
MyHomeStuff.js
編輯:
views.py `
def offlineApp(request):
t = get_template('index.html')
html = t.render(Context({'MEDIA_URL':'http://myDomain.com/site_media/'}))
return HttpResponse(html)
EDIT2
是使用任何特定module/middleware
來處理django
text/manifest
需要它?
該應用程序按預期方式適用於Chrome,Opera和其他桌面瀏覽器;但在Android 2.x,iPhone瀏覽器的飛行模式下不會加載。但它適用於Android 4.0瀏覽器!
可能是什麼問題?請幫忙。
好的!所以我得到了一些**解決方法**。我用[宣言](https://github.com/cyberdelia/manifesto)在django中實現離線應用程序。不過,我仍然在尋找只使用django的簡單解決方案(即,不需要像宣言那樣的附加軟件包) – ranjjose 2013-02-23 07:54:00