Loading .epub files and TOC on IE and Windows Safari doesn't work
Both examples contained.html and promises.html have problems with IE10, IE11 and Windows Safari 5.1.7. The TOC isn't generated (dropdown remains empty) and loading the book from a compressed .epub file results an empty page. This is similar behaviour on all the mentioned browsers.
@gness could you provide more details such as any console errors?
When viewing the examples/contained.html or examples/promises.html in Windows Safari or IE, the error log is empty. What I get is basically a white screen with navigational arrows for contained.html and empty dropdown for the promises.html
Same issue here on IE11
Sorry, console is in french :
DOM7011: Le code de la page a désactivé la mise en cache précédente et suivante. Pour plus d’informations, voir : http://go.microsoft.com/fwlink/?LinkID=291337 Fichier : contained.html HTML1300: Une navigation s’est produite. Fichier : contained.html HTML1202: http://www.mydomain.com/epub/examples/contained.html fonctionne en affichage de compatibilité car l’option « Afficher les sites intranet dans Affichage de compatibilité » est sélectionnée. Fichier : contained.html Could not load Chapter: OPS/cover.xhtml TypeError: Impossible d’obtenir la propriété « indexOf » d’une référence null ou non définie "Could not load Chapter: OPS/cover.xhtml" { [functions]: , proto: { [functions]: , proto: { }, message: "", name: "TypeError" }, description: "Impossible d’obtenir la propriété « indexOf » d’une référence null ou non définie", message: "Impossible d’obtenir la propriété « indexOf » d’une référence null ou non définie", name: "TypeError", number: -2146823281, stack: "TypeError: Impossible d’obtenir la propriété « indexOf » d’une référence null ou non définie at EPUBJS.core.uri (http://www.mydomain.com/epub/build/epub.js:4090:4) at EPUBJS.core.resolveUrl (http://www.mydomain.com/epub/build/epub.js:4263:3) at Anonymous function (http://www.mydomain.com/epub/build/epub.js:3923:5) at Anonymous function (http://www.mydomain.com/epub/build/epub.js:3888:3) at EPUBJS.Chapter.prototype.replace (http://www.mydomain.com/epub/build/epub.js:3877:2) at EPUBJS.Chapter.prototype.replaceWithStored (http://www.mydomain.com/epub/build/epub.js:3921:2) at EPUBJS.replace.svg (http://www.mydomain.com/epub/build/epub.js:7873:2) at Anonymous function (http://www.mydomain.com/epub/build/epub.js:5222:4) at hooks.prototype.triggerHooks (http://www.mydomain.com/epub/build/epub.js:5221:3) at Anonymous function (http://www.mydomain.com/epub/build/epub.js:3626:4)" }
In IE, document.evaluate fails silently (not supported in IE), which is used to generate the XPath results for populating the TOC. The easiest workaround is to use getElementsByTagName to return the needed document nodes.
In reader/js/epub.min make the following changes:
lines 5558 and 5559 change from:
var navMap = tocXml.querySelector("navMap");
if(!navMap) return [];
to:
var navMap = tocXml.getElementsByTagName('navPoint');
if(!navMap) return [];
lines 5563 and 5564 change from:
snapshot = tocXml.evaluate("*[local-name()='navPoint']", parent, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null),
length = snapshot.snapshotLength;
to:
length = parent.length;
line 5569 change from:
var item = snapshot.snapshotItem(i);
to:
var item = parent[i];
line 5571 change from:
var id = item.getAttribute('id') || false,
to:
var id = item.id || false,
line 5599 change from:
"parent" : parent ? parent.getAttribute('id') : null,
to:
"parent" : parent ? parent.id : null,
This produces a TOC in IE based on my testing.
@claytonk. Thanks so much for looking into this. I'll update master with a check for document.evaluate and use this code if it fails.