satorumurmur / bibi

Bibi | EPUB Reader on your website.
https://bibi.epub.link
MIT License
843 stars 123 forks source link

javascript error in EPUB on Edge or Firefox browser #52

Closed kenkiku1021 closed 4 years ago

kenkiku1021 commented 6 years ago

When using javascript in the EPUB document for XHR, MS Edge browser and Firefox cannot get XHR target.

example

http://example.com/bibi/

+bookshelf
 +book1
   +OEBPS
    -p1.xhtml
    -p1.js
    -data.json
+i
 -index.html
// p1.js
document.addEventListener("DOMContentLoaded", function() {
  var xhr = new XMLHttpRequest();
  xhr.open("GET", "data.json");
  xhr.send();
  alert(location.href);
});

result

Chrome / Safari / IE11

Can get "data.json", alert shows : http://example.com/bibi/bookshelf/book1/OEBPS/p1.xhtml

Edge / Firefox

Cannot get "data.json" and XHR request send to wrong URI (http://example.com/bibi/i/data.json). alert shows : http://example.com/bibi/i/?book=book1 It seems that document in the BiBi's iframe recognize wrong location.

I know that I should not use javascript and XHR in the EPUB. But I want to use it.

satorumurmur commented 4 years ago

It seems difficult to get to your request, sorry.