Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

254
Visualizações
epub.js - show book in 1 simple html file

im trying to create a simple html that will use epub.js to show a book. cause later i want to use it in my react native app.

tried to load local file and fil from url . both didnt work

epub.js: https://github.com/futurepress/epub.js

what am i missing ? why isnt the book loading ?

here is my code:

<!DOCTYPE html>
<html lang="en">

  <head>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jszip/3.1.5/jszip.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/epubjs/dist/epub.min.js"></script>
<style>
  body {
    margin: 0;
  }

  #reader {
    height: 400px;
    width: 400px;
    overflow: hidden !important;
    display: flex;
    justify-content: center;
    align-items: center;
  }

</style>
  </head>

  <body>
<div id="reader" style="background-color: antiquewhite; width: 400px; height: 400px"></div>
  </body>
  <script>
try {
  //let bookUrl = 'https://filesamples.com/samples/ebook/epub/Sway.epub'
  let bookUrl = './Sway.epub'
  let epubReader = ePub(bookUrl);

  //works
  var request = new XMLHttpRequest();
  request.open('GET', bookUrl, true);
  request.onreadystatechange = function() {
    if (request.readyState === 4) {
      if (request.status === 404) {
        alert("Oh no, it does not exist!");
      } else {
        alert("book exists!!!!"); //this is fired!!!
      }
    }
  };
  request.send();

  var book = ePub(bookUrl);
  var rendition = book.renderTo("reader", {
    width: 400,
    height: 400
  });
  var displayed = rendition.display();
} catch (e) {
  alert('error 1' + e)
}

  </script>

</html>

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda