简体   繁体   中英

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

I want to read the EPUB files which are located in Assets folder. I have a HTML file. In which i have referred epub.min.js and provided a epub file location to read the file. But the epub file was not loaded. Can anyone suggest me how to read epub files using html and javascript in Android?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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