MobileRead Forums

MobileRead Forums (https://www.mobileread.com/forums/index.php)
-   Viewer (https://www.mobileread.com/forums/forumdisplay.php?f=281)
-   -   Viewer seems not to load some scripts (https://www.mobileread.com/forums/showthread.php?t=341549)

RbnJrg 09-02-2021 04:50 PM

Viewer seems not to load some scripts
 
3 Attachment(s)
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:

Attachment 189070

However, the Calibre book viewer only displays text without any formatting:

Attachment 189071

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

MicroDrie 09-02-2021 07:53 PM

1 Attachment(s)
Quote:

Originally Posted by RbnJrg (Post 4151230)
The attached epub makes use of java scripts 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:

Attachment 189070

However, the Calibre book viewer only displays text without any formatting:

Attachment 189071

Obviously the Book Viewer is not loading the java scripts 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

When I open your EPUB in Sigil, the formatting works in the preview screen. If I open your EPUB in the external PageEdit program, it doesn't work. If I open the EPUB on my old Galaxy J7 in the GitDen E-reader, it works.

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-">
This modified version also works flawlessly in my GitDen app on the Galaxy J7.

Regards MicroDrie

RbnJrg 09-02-2021 09:18 PM

Quote:

Originally Posted by MicroDrie (Post 4151262)
When I open your EPUB in Sigil, the formatting works in the preview screen. If I open your EPUB in the external PageEdit program, it doesn't work. If I open the EPUB on my old Galaxy J7 in the GitDen E-reader, it works.

Hi MicroDrie;

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:

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.
Yes, you are right and I am aware of that. For example, my epub doesn't work on ADE 4.5x (with supports for epub3 and java). The issue here is that Calibre can display the epub flawlessly in its Book Editor. So, in theory, it should run (the epub) also in the Book Viewer. I think there must be something in the way the Viewer processes the function calls. But I'm not sure about that.

Regards to you too.
Rubén

kovidgoyal 09-03-2021 01:05 AM

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.


All times are GMT -4. The time now is 09:32 PM.

Powered by: vBulletin
Copyright ©2000 - 3.8.5, Jelsoft Enterprises Ltd.
MobileRead.com is a privately owned, operated and funded community.