【问题标题】:Webview not working as desired in case of HTML5 cache在 HTML5 缓存的情况下,Webview 无法正常工作
【发布时间】:2013-01-04 04:24:38
【问题描述】:

我使用 Titanium Appcelerator 创建了一个应用程序,在该应用程序中我使用 web 视图来显示一些网页。在 webview 中显示的所有网页都启用了 HTML5 缓存,因为我希望即使应用程序脱机运行,这些网页也可用。

我面临的问题是,当没有网络连接时,webview 无法显示缓存的网页。但是我已经在浏览器中测试了所有网页,并且它们都可以正常工作。

我在 Android 平台上遇到了这个问题。

这是网页视图的代码:

 //FirstView Component Constructor
function FirstView() {
    //create object instance, a parasitic subclass of Observable
    var self = Ti.UI.createView();




 var webview = Ti.UI.createWebView({
    url: 'http://www.w3schools.com/html/tryhtml5_html_manifest.htm'
});


self.add(webview);


    return self;
}

module.exports = FirstView;

这个网址在浏览器中运行良好。我该如何解决这个问题?

【问题讨论】:

    标签: android html caching webview titanium


    【解决方案1】:

    您可以使用本地 html,它使用 jquery .ajax 加载另一个这样的网页 //在本地页面内

     <div id="pull"></div>
     <script>
     $.ajax({
     url: "http://www.w3schools.com/html/tryhtml5_html_manifest.htm",
     cache: true,type: "POST"}).done(function( html ) {
     $("#pull").append(html);  
     });
    </script>
    

    【讨论】:

      猜你喜欢
      • 2013-03-04
      • 1970-01-01
      • 1970-01-01
      • 2020-06-27
      • 1970-01-01
      • 1970-01-01
      • 2017-03-16
      • 2018-07-02
      • 2013-04-14
      相关资源
      最近更新 更多