View Full Version : Javascript in ePub


Techno4
05-31-2012, 12:47 PM
I made a crossword puzzle using software that automatically exports as an html page with css and javascript externally linked. What's the best way to put this into my epub. Will this work in epub? I know that js is supported in epub 3, yes I know many readers don't have epub3 capabilities yet. I'm just asking

1) Will a js crossword puzzle work in my epub

2) Already having the .epub file what's the best way to go about inserting my html page with my crossword puzzle, and the css / js pages that accompany it.

Thanks ;)

-Techno

frostschutz
05-31-2012, 02:50 PM
There's no JS in EPUB. Or any other way for interactive content for that matter. So no, it won't work. Not unless you create a static page for every possible state and give the reader instructions such as (if you want to put A in field x,y continue on page 9155)

Techno4
06-01-2012, 09:07 AM
Sorry I suppose I meant "enhanced" epub3. If you're saying there is no javascript in epub whatsoever, then it appears either

1)I need a more knowledgeable poster

or

2)The interactive epubs I've been looking at that are noted as using javascript, are all lies.

Thanks :)

DaleDe
06-02-2012, 01:02 AM
yes, ePub 3 will support Javascript but you already knew that. In the context of why would you ask a question you already know the answer to, no the current ePub (version 2) does not support javascript.

Techno4
06-05-2012, 10:39 AM
DaleDe,

Do you know the answer to this question:

Already having the .epub file what's the best way to go about inserting my html page with my crossword puzzle, and the css / js pages that accompany it?

I was looking for a forum to best post this question in, because I'm having trouble trying to integrate the javascript. I'm currently using sigil and inserting the javascript into the Misc folder, and then relinking the html page. However, this isn't providing the best results. I suppose what I'm really asking is, is there an alternative to sigil for editing the actual HTML pages that is epub specific (i.e not textwrangler / textedit or other basic html editers). With 8,131 posts and I'm sure counting I would've thought that your answer could've been more helpful, however it wasn't.

I didn't ask if epub 3 will support javascript (you can reference my first post), I'm asking if it will support a javascript crossword puzzle. A question that only someone who has hopefully tried this before would've been able to answer. So please, why artificially bump that post count up and not answer my question at the same time :)?

DaleDe
06-06-2012, 12:39 PM
I was clarifying and correcting frostschutz post, it was not aimed at your post. It looked like you might be asking about trying something in 2.0 since you were asking about Sigil. Sigil does not support 3.0. Our wiki talks about ePub 3 and currently is weak on Javascript but have plenty of offsite links that may help. Once you figure it out please update our wiki.

I have believe that crossword puzzle should work since javascript is supported although it may be difficult to find a good reader.

I am not just posting to bump up the thread. This is a discussion group, not Ask and answer.com

Dale

Doitsu
06-06-2012, 04:38 PM
Implementing a crossword puzzle as an ebook would be difficult even under ideal circumstances. Have you considered creating an app instead? There are couple of free programs available that let you design apps with HTML and JavaScript only.
You can read about it for example in Building iPhone Apps with HTML, CSS, and JavaScript (http://ofps.oreilly.com/titles/9780596805784/), which you can you access for free at the O'Reilly web site. (There are also similar tools for Android based phones and tablets.)

whbenson
06-07-2012, 10:59 PM
I don't know how hard it would be to get your specific crossword code to work, but here's a few comments about javascript with Sigil:
You can place javascript directly in the <head> section if you escape it via CDATA something like so:
<script type="text/javascript">
//<![CDATA[
function setup() {
//...
{
window.onload=setup;
//]]>
</script>

If you prefer to work with an external file, I'll just mention that if you place it in the Styles folder - with a .css extension instead of .js - you can then edit it with Sigil and the javascript code still works.

AFAIK, iBooks is the only reader that pays attention to the javascript, with the possible exception of the Kobo iOS reader.
-Bill

Techno4
06-08-2012, 08:28 AM
I don't know how hard it would be to get your specific crossword code to work, but here's a few comments about javascript with Sigil:
You can place javascript directly in the <head> section if you escape it via CDATA something like so:
<script type="text/javascript">
//<![CDATA[
function setup() {
//...
{
window.onload=setup;
//]]>
</script>

If you prefer to work with an external file, I'll just mention that if you place it in the Styles folder - with a .css extension instead of .js - you can then edit it with Sigil and the javascript code still works.

AFAIK, iBooks is the only reader that pays attention to the javascript, with the possible exception of the Kobo iOS reader.
-Bill


Bill,

I had the code to load the script however I didn't have the CDATA information. I added it and my crossword is working as intended. TYVM!

-Techno4

Khululekani
11-05-2012, 12:50 PM
Let no one tell you otherwise unless they have tried and failed. Your puzzle should work fine without an issues, i have developed epubs with advanced interactions. U can hook me up with your puzzle and i will give you a demo how to implement it into your epub book.

I made a crossword puzzle using software that automatically exports as an html page with css and javascript externally linked. What's the best way to put this into my epub. Will this work in epub? I know that js is supported in epub 3, yes I know many readers don't have epub3 capabilities yet. I'm just asking

1) Will a js crossword puzzle work in my epub

2) Already having the .epub file what's the best way to go about inserting my html page with my crossword puzzle, and the css / js pages that accompany it.

Thanks ;)

-Techno