2

我有一本 iBooks EPUB3 书,具有以下目录结构:

mimetype
META-INF (=dir)
OPS (=dir)
   scripts (=dir)
      jquery-2.1.1.min.js
      version.js
   Styles (=dir)
      stylesheet.css
   package.opf
   about.xhtml

等等

Version.js 包含:

$(document).ready(function(){
$.get ('package.opf',    <-- this correct? 
       function(xml) {
   $("span#datum").html($(xml).find("meta[property='dcterms\\:modified']").text());
   $("span#versie").html($(xml).find("meta[property='ibooks\\:version']").text());
   });
});

About.xhtml 有一行

<script type="text/javascript" src="scripts/version.js"></script>

在它的正文中,显示 package.opf 中包含的修改日期和版本号。至少,是这样的想法。但事实并非如此。问题1:version.js中package.opf的路径是否正确?

问题 2:在 iBooks EPUB3 书籍中是否可以像这样从 .opf 文件进行内部读取?

4

1 回答 1

0

Great question.

Part 1: most likely, no: the path is no-longer correct. iBooks rips apart the ePub and puts things in it's own special places. You can see this in action with images by doing something like this:

$(".anImg").on("tap",function(){
    alert(event.target.src);
})

The function above will display something like this: "ibooksimg://BOOKID/Images/theImg.png". Due to the first part of this path (ibooksimg) I doubt the relative structure within your book is staying the same.

Part 2: Internal reading from ANY file in iBooks is something I believe to be impossible at this moment. I have never had any luck using GET requests or XHR from within iBooks: Apple has made this sort of in-file communication very difficult.

Suggestions: what we do is put all of our versioning info etc inside our JS documents as a json variable. Javascript files are the only type that seem to play nice with Apple (you can include them in your headers etc). It's a shame but better than nothing...

于 2014-06-12T18:28:20.360 回答