我想知道如何使用Epub.js转到Epub中的特定页面。
通过在当前页面中单击记录redention对象,我可以获得位置,但之后我不知道如何使用它。
book.ready.then(function () {
var saveBookMark = function () {
console.log(rendition.currentLocation());
// I could save the location here
};
var addBookMark = document.getElementById('add-bookmark');
addBookMark.addEventListener("click", saveBookMark, false);
});如果我在使用之前获得的位置后执行此操作:
var bookmark = {
href: 'Text/Chapter1_06a.xhtml',
};
history.pushState({}, '', "?loc=" + encodeURIComponent(bookmark.href));我可以转到那一章,但不能转到书签所在的页面。
这是在当前页面中单击时重命名后得到的对象。
redention.location = {
end: {
cfi: "epubcfi(/6/26[Chapter1_06a.xhtml]!/4/2/124/10/3:22)",
displayed: {page: 8, total: 8},
href: "Text/Chapter1_06a.xhtml",
index: 12,
location: -1,
percentage: 0,
},
start: {
index: 12,
href: "Text/Chapter1_06a.xhtml",
cfi: "epubcfi(/6/26[Chapter1_06a.xhtml]!/4/2/110/1:242)",
displayed: {…},
location: -1,
…
}
}发布于 2019-09-17 12:47:32
您已经展示了代码片段,但并不是全部。看起来你有一个拼写错误:rendition和redention不一样。
无论如何,rendition.gotoCfi(some_cfi)应该能做到这一点。您甚至可能不需要rendition对象;您也可以调用book.goto(some_cfi)。
https://stackoverflow.com/questions/57949506
复制相似问题