|  07-13-2023, 10:43 AM | #1 | 
| Junior Member  Posts: 9 Karma: 10 Join Date: Feb 2023 Device: kobo h2o |  epub3 javascript in Kobo 
			
			Hello I am trying to develo a stupid epub, but a problem arised I cannot solve. May be someone faced it. I composed an epub3 using Sigil, with a single HTML page, like this : <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"> <head> <title></title> <script type="text/javascript"> function myFun(k) { this.item = k; } </script> </head> <body> <div id="number_one"> <script type="text/javascript"> const c = new myFun("test"); document.getElementById("number_one").innerHTML = c.item; </script> </div> </body> </html> it works fine on any reader I checked, and also on Kobo devices (Aura and Libra). If I try to use an external file for the function, like this: xml version="1.0" encoding="utf-8"?> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops"> <head> <title></title> <script type="text/javascript" src="../Misc/Script0001.js"></script> </head> <body> <div id="number_one"> <script type="text/javascript"> const c = new myFun(" test 01 : from external file"); document.getElementById("number_one").innerHTML = c.item; </script> </div> </body> </html> and script Script0001.js : function myFun(k) { this.item = k; } it works on Thorium, on Adobe Digital, on Sigil previewer but DON'T work on Kobo. Of course I checked opf, mimetype, etc, etc. I never got errors, epub checkers say it's fine, but no way. Could someone help me? Thanks a lot | 
|   |   | 
|  07-13-2023, 12:26 PM | #2 | 
| Bibliophagist            Posts: 48,100 Karma: 174315444 Join Date: Jul 2010 Location: Vancouver Device: Kobo Sage, Libra Colour, Lenovo M8 FHD, Paperwhite 4, Tolino epos | 
			
			The question that comes to mind is if you sent it to your Kobo as a .kepub.epub to trigger the WebKit based renderer. If you send it as an epub, you will use the Adobe RMSDK renderer which is more limited on what it will accept.
		 | 
|   |   | 
| Advert | |
|  | 
|  07-14-2023, 02:34 AM | #3 | 
| Junior Member  Posts: 9 Karma: 10 Join Date: Feb 2023 Device: kobo h2o | 
			
			Thanks for your answer. I forgot to state that I made both the tryes. I used 3 or 4 different tools to translate in kepub (calibre, kepubify, etc.), and the result was always the same of epub: no way! | 
|   |   | 
|  07-15-2023, 01:19 AM | #4 | |
| Guru            Posts: 983 Karma: 2209358 Join Date: Nov 2011 Location: London, UK Device: Kobo Aura, Kobo Aura ONE, PocketBook InkPad Color 3 | 
			
			Shouldn't your second test use: Quote: 
 Is Script0001.js in the manifest? If you're using Sigil I'd expect it to keeping that up-to-date. | |
|   |   | 
|  07-15-2023, 06:25 AM | #5 | 
| Junior Member  Posts: 9 Karma: 10 Join Date: Feb 2023 Device: kobo h2o | 
			
			Yes, the file is in the manifest. I didn’t understand where I should use that script row, sorry. | 
|   |   | 
| Advert | |
|  | 
|  07-17-2023, 02:48 AM | #6 | 
| Junior Member  Posts: 9 Karma: 10 Join Date: Feb 2023 Device: kobo h2o | 
			
			Hi Chrisridd I finally got what you said, and I made a try, but the result didn't change. Thank you for the correction. | 
|   |   | 
|  07-17-2023, 03:44 AM | #7 | 
| Guru            Posts: 983 Karma: 2209358 Join Date: Nov 2011 Location: London, UK Device: Kobo Aura, Kobo Aura ONE, PocketBook InkPad Color 3 | 
			
			Kobo's a bit ambiguous about their Javascript support on e-ink. Here it says there's limited support: https://github.com/kobolabs/epub-spe...script-support But here it says it isn't supported at all: https://github.com/kobolabs/epub-spec#support-grid | 
|   |   | 
|  07-17-2023, 06:36 AM | #8 | 
| Junior Member  Posts: 9 Karma: 10 Join Date: Feb 2023 Device: kobo h2o | 
			
			Yes, I read that document. As you can see from my little test, it seems than javascript is supported and working, but it is not if functions are in external files. I can't undenrstand, external files for fonts and styles are read correctly, so external files js should be read as well... | 
|   |   | 
|  07-17-2023, 08:06 AM | #9 | |
| Still reading            Posts: 14,990 Karma: 111111255 Join Date: Jun 2017 Location: Ireland Device: All 4 Kinds: epub eink, Kindle, android eink, NxtPaper | Quote: 
 Really only non-ereader apps should execute programs. | |
|   |   | 
|  07-17-2023, 10:16 AM | #10 | 
| Junior Member  Posts: 9 Karma: 10 Join Date: Feb 2023 Device: kobo h2o |   
			
			If someone is interested, I found a way for executing javascript from extern files. Don't ask me why or what, but I saw that if the epub contains MINIFIED js files, it works correctly on Kobo Aura, Kobo Touch and Kobo Libra. I made some test on the same epub I posted at the beginning, and on some other file, and the result is OK: if js file is minified it works on Kobo. Last edited by laverdure; 07-17-2023 at 10:17 AM. Reason: Missing info | 
|   |   | 
|  07-19-2023, 11:02 AM | #11 | 
| Guru            Posts: 983 Karma: 2209358 Join Date: Nov 2011 Location: London, UK Device: Kobo Aura, Kobo Aura ONE, PocketBook InkPad Color 3 | |
|   |   | 
|  | 
| Tags | 
| epub3, javascript, kobo | 
| 
 | 
|  Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post | 
| EPUB3: resize SVG in javascript | fbrzvnrnd | ePub | 32 | 02-03-2017 04:39 AM | 
| ePub3: localStorage/JavaScript/RTL support | Doitsu | ePub | 7 | 06-02-2015 06:55 AM | 
| Is there any android epub reader supporting epub3 with audio/video/javascript? | happycoding | Android Developer's Corner | 10 | 07-29-2014 11:16 AM | 
| Create a javascript quizz for Epub3 in Sigil | BertrandThibaut | Sigil | 3 | 01-26-2014 09:04 AM | 
| JAVASCRIPT support in ePub2/ePub3 | Raja1205 | ePub | 7 | 09-03-2012 06:48 AM |