09-02-2021, 03:50 PM | #1 |
Wizard
Posts: 1,599
Karma: 7999999
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Viewer seems not to load some scripts
The attached epub makes use of javascripts to achieve certain text effects with a minimum of html markup (all the work is made on the css stylesheet). The epub is perfectly displayed by the Calibre Book Editor, as you can see in the image below:
However, the Calibre book viewer only displays text without any formatting: Obviously the Book Viewer is not loading the javascripts and, I wonder why? I have included the keyword "defer" in the script tags but without result. It also doesn't work to move the scripts to the bottom of the page (above the </body> tag). I would like to know if all this is because I am doing something wrong, or because of a bug in the book viewer. Regards Last edited by RbnJrg; 09-02-2021 at 06:55 PM. |
09-02-2021, 06:53 PM | #2 | |
Connoisseur
Posts: 58
Karma: 438844
Join Date: Aug 2019
Device: PC, Linux Mint, Tablet, and Telephone
|
Quote:
The fact that JavaScript can work on an E-reader does not mean that all (combinations) of HTML, CSS and JavaScript code can also work in all E-readers and EPUB apps. In addition, for example, Google Play Books does not allow JavaScript and Javascript must be allowed on the E-reader. I don't think the problem is the JavaScript not loading, but the EPUB render software version not being recognized. To make your EPUB work properly in PageEdit I've put a webkit class over the HTML on both chapters to make it work: Code:
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" class=" -webkit-"> Regards MicroDrie |
|
Advert | |
|
09-02-2021, 08:18 PM | #3 | ||
Wizard
Posts: 1,599
Karma: 7999999
Join Date: Mar 2013
Location: Rosario - Santa Fe - Argentina
Device: Kindle 4 NT
|
Quote:
I appreciate your answer. What version of PageEdit are you using? Because I can open the posted epub on PageEdit without adding the "-webkit-" class. In fact, the script prefixfree.min.js is precisely for that; to avoid using any prefix (the script according to the ereader, adds the proper prefix [-moz, -ms, -webkit] to whatever -headers, styles, etc.). Quote:
Regards to you too. Rubén |
||
09-03-2021, 12:05 AM | #4 |
creator of calibre
Posts: 44,371
Karma: 23764838
Join Date: Oct 2006
Location: Mumbai, India
Device: Various
|
In order to work in web browsers, the viewer virtualizes loading of scripts, so their load order is no longer preserved. If you right click and open the inspector in the console you will see an error about jQuery not being defined. You can fix it by wrapping the entire ntheverything code to run only on the load event.
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
window.load event: works in editor but not in viewer | jrv | Viewer | 6 | 02-15-2021 10:15 PM |
Viewer takes ages to load books | GertNL01 | Viewer | 6 | 01-21-2021 04:07 PM |
Collection of runme scripts | knc1 | Kindle Developer's Corner | 23 | 08-17-2018 01:48 AM |
calibre failed to load after 1.12.0 down load | junglered | Recipes | 2 | 11-27-2013 10:15 PM |
E-book viewer takes forever to load flow | Iznogood | Calibre | 7 | 04-06-2013 11:37 PM |