Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/189.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
JavaScript函数没有';t在Android Jelly Beans及以下版本的WebView中工作_Javascript_Android_Webview_Epub_Android 4.1 Jelly Bean - Fatal编程技术网

JavaScript函数没有';t在Android Jelly Beans及以下版本的WebView中工作

JavaScript函数没有';t在Android Jelly Beans及以下版本的WebView中工作,javascript,android,webview,epub,android-4.1-jelly-bean,Javascript,Android,Webview,Epub,Android 4.1 Jelly Bean,在Android应用程序中,我试图通过WebView显示EPUB书籍。浏览我正在使用的书,以及一些视觉效果。当我在使用安卓KitKat(4.4)或更高版本的设备上运行我的应用程序时,这很好,但如果我尝试以下版本,如Jelly Beans(4.3)。Epub.js的一些功能不起作用,例如Book.prev,Book.next,Book.goto(url)和Book.renderTo()等其他功能仍然可以正常工作,我可以获得所有书籍章节 我将所有代码放在一个javascript文件中,如下所示 fu

在Android应用程序中,我试图通过WebView显示EPUB书籍。浏览我正在使用的书,以及一些视觉效果。当我在使用安卓KitKat(4.4)或更高版本的设备上运行我的应用程序时,这很好,但如果我尝试以下版本,如Jelly Beans(4.3)。
Epub.js
的一些功能不起作用,例如
Book.prev
Book.next
Book.goto(url)
Book.renderTo()
等其他功能仍然可以正常工作,我可以获得所有书籍章节

我将所有代码放在一个javascript文件中,如下所示

function init_js_code(url){
               var Book = ePub(url, { restore: true});
               Book.getMetadata().then(function(meta){
                  document.title = meta.bookTitle;

              });
              $( "#next" ).click(function() {
                    Book.nextPage();
              });
              $( "#prev" ).click(function() {
                    Book.prevPage();
              });

              Book.getToc().then(function(toc){
                var $select = document.getElementById("toc"),
                    $docfrag = document.createDocumentFragment();
                var cList = $('ul.nav-primary');
                toc.forEach(function(chapter) {
                  // logic to create a menu
                });

              });
              Book.ready.all.then(function(){
                document.getElementById("loader").style.display = "none";
              });
              Book.renderTo("area");
在html文件中,只需调用此函数

<head>
<script src="jquery.js"></script>
...
</head>
<body>
...
<script>
          function getPDFURL(){
                 ...
          }

          var url = 'http://' + getPDFURL() + '.epub';
          init_js_code(url);
    </script>
</body>
虽然问题出在哪里,但是一些Javascript函数在这个设备中被阻塞了?
还有其他方法吗?

4.4
只是比
4.3
有更多的html5/js功能,在此之前,代码使用的是一个或多个web平台功能。
4.4
只是比
4.3
有更多的html5/js功能,在此之前,代码使用的是一个或多个web平台功能。
final WebView webView = (WebView) findViewById(R.id.webView1);
    WebSettings settings = webView.getSettings();
    settings.setJavaScriptEnabled(true);
    settings.setDomStorageEnabled(true);
    if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.JELLY_BEAN) {
        settings.setAllowUniversalAccessFromFileURLs(true);
    }

    if(android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.KITKAT) {
        WebView.setWebContentsDebuggingEnabled(true);
    }
    if(android.os.Build.VERSION.SDK_INT > android.os.Build.VERSION_CODES.HONEYCOMB) {
        settings.setDisplayZoomControls(false);
    }
    webView.setWebChromeClient(new WebChromeClient() {
        public void onProgressChanged(WebView view, int progress)
        {
            ..
        }
    });
    webView.loadUrl("file:///android_asset/.../index.html?url="+material_url);