View Single Post
Old 07-13-2023, 10:43 AM   #1
laverdure
Junior Member
laverdure began at the beginning.
 
Posts: 9
Karma: 10
Join Date: Feb 2023
Device: kobo h2o
Angry 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
laverdure is offline   Reply With Quote