简体   繁体   English

使用Android资源文件夹中的HTML和Javascript读取Epub文件?

[英]Read Epub Files using HTML and Javascript from Android Asset folder?

I want to read the EPUB files which are located in Assets folder. 我想读取位于Assets文件夹中的EPUB文件。 I have a HTML file. 我有一个HTML文件。 In which i have referred epub.min.js and provided a epub file location to read the file. 我在其中引用了epub.min.js并提供了一个epub文件位置来读取该文件。 But the epub file was not loaded. 但是没有加载epub文件。 Can anyone suggest me how to read epub files using html and javascript in Android? 谁能建议我如何在Android中使用html和javascript阅读epub文件?

File Locations 文件位置

Asset/Sample/index.html
Asset/sample/epub.min.js
Asset/Sample/jquery-1.10.2.min.js
Asset/Sample/Epub file folder. All html, images are available in this folder

<!DOCTYPE html>
<html class="no-js">
    <head> 
        <script src="jquery-1.10.2.min.js"></script>
            <!-- Render -->
            <script src="epub.min.js"></script> 
        <script type="text/javascript">    
        var book = ePub("Azure_Cosmos_DB_and_DocumentDB_Succinctly/");
          $(document).ready(function () {
          book.renderTo("area");
        });        
    </script>
    </head>
    <body>
 <div id="main">
    <div id="prev" onclick="book.prevPage()" style="font-size: 64px;cursor:pointer;" class="arrow">‹</div>
    <div id="area" style="height:500px;"></div>
    <div id="next" onclick="book.nextPage()" style="font-size: 64px;cursor:pointer;" class="arrow">›</div>    
</div>    
    </body>
</html>

Try this. 试试这个。

if(Build.VERSION.SdkInt >= Build.VERSION_CODES.JellyBean)
{
 webView.Settings.AllowUniversalAccessFromFileURLs = true; 
 webView.Settings.AllowFileAccessFromFileURLs = true;
}

Also please keep the script files directly in asset folder instead of keeping to inner folders. 另外,请将脚本文件直接保存在资源文件夹中,而不是保留在内部文件夹中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM