![]() |
#1 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Nov 2010
Device: ADE
|
Javascript in ePub.
How to embed javascript in ePub, anybody having samples or any resource.
![]() |
![]() |
![]() |
![]() |
#2 |
frumious Bandersnatch
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 7,542
Karma: 19001583
Join Date: Jan 2008
Location: Spaniard in Sweden
Device: Cybook Orizon, Kobo Aura
|
Javascript is not supported by the ePUB spec, nor by most ePUB readers.
|
![]() |
![]() |
![]() |
#3 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Nov 2010
Device: ADE
|
|
![]() |
![]() |
![]() |
#5 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 1,196
Karma: 1281258
Join Date: Sep 2009
Device: PRS-505
|
As Jellby said, the current standard doesn't provide for embedded media or scripting. There are a couple of non-standard solutions, though they should only be used if you are only targeting a specific reading device.
Here's Liza Daly's post on using JavaScript with iBooks. As with the other link, this will only work on the iPad. Adobe's reading system will recognise flash elements, there's an example here. This won't work on the majority of device implementations, but does work on the desktop reader. |
![]() |
![]() |
![]() |
#6 |
Developer
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 345
Karma: 3473
Join Date: Apr 2007
Location: Brooklyn, NY, USA
Device: iRex iLiad v1, Blackberry Tour, Kindle DX, iPad.
|
Liza Daly's example (linked by charleski above) is a great place to start.
Two important things to note:
|
![]() |
![]() |
![]() |
#7 |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 37
Karma: 493532
Join Date: May 2010
Device: ipad
|
FWIW, the following sample code works in both Sigil and iBooks.
Code:
<?xml version="1.0"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title></title> <script type="text/javascript"> //<![CDATA[ alert("screen width=" + screen.width); //]]> </script> </head> <body> </body> </html> -Bill |
![]() |
![]() |
![]() |
#8 |
Junior Member
![]() Posts: 8
Karma: 10
Join Date: Nov 2010
Device: ADE
|
i tried with monocle reader, its too supporting javascript.
@ Bill. your example is good, i tried with that its working. thnks.. |
![]() |
![]() |
![]() |
#9 |
Junior Member
![]() Posts: 2
Karma: 10
Join Date: Sep 2011
Device: iPad
|
Hello!
I have watched liza's video and am pumped about the prospects for education. Any advice on where to read up/find examples on actually putting together an ePub with javascript and interactivity? Thanks! |
![]() |
![]() |
![]() |
#10 |
Media Bloke
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 2,381
Karma: 113956855
Join Date: Sep 2010
Location: NSW - Australia
Device: iOS
|
G'gay Killa' welcome to the forums.
You could try Liz Castro's comments. Be aware that adding Java to an ePub will limit your audience. I don't think many reading devices will support it. |
![]() |
![]() |
![]() |
#11 |
Junior Member
![]() Posts: 1
Karma: 10
Join Date: Nov 2011
Device: ipad
|
bill, i have tried the exact code you posted, and it crashes sigil.
the alert window pops up twice, then a fatal error occurs. i am using windows 7 64 bit and sigil 0.4.2 any ideas what may cause this behavior? |
![]() |
![]() |
![]() |
#12 |
Wizard
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 4,520
Karma: 121692313
Join Date: Oct 2009
Location: Heemskerk, NL
Device: PRS-T1, Kobo Touch, Kobo Aura
|
Could be anything. Javascript is not supported as far as I know and it is still not in the specifications of ePUB. So it is kind of hit and miss.
|
![]() |
![]() |
![]() |
#13 | |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 37
Karma: 493532
Join Date: May 2010
Device: ipad
|
Quote:
Code:
<head> <title></title> <script type="text/javascript"> //<![CDATA[ function hitme() { alert("screen width=" + screen.width); } //]]> </script> </head> <body> <p onclick="hitme()">hit me</p> </body> </html> |
|
![]() |
![]() |
![]() |
#14 |
Evangelist
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 416
Karma: 14682
Join Date: May 2008
Location: SF Bay Area
Device: Nook HD, Nook for Windows 8
|
Javascript is allowed in EPUB3 documents, but not EPUB2 documents. Any Reader that is not using WebKit (ie Adobe RMSDK) will only handle EPUB2 documents, and that's the vast overwhelming majority right now. As mentioned above, iBooks is the closest to an EPUB3 reader that is out there right now.
|
![]() |
![]() |
![]() |
#15 | |
Enthusiast
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() Posts: 37
Karma: 493532
Join Date: May 2010
Device: ipad
|
Quote:
|
|
![]() |
![]() |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
epub et javascript | zelda_pinwheel | Software | 9 | 12-09-2010 04:56 PM |
Javascript and Bookmarklets | Polvo | Kindle Developer's Corner | 0 | 10-17-2010 05:54 AM |
I need Javascript help | Nate the great | Workshop | 4 | 04-04-2009 12:55 AM |
iLiad Javascript? | jsc | iRex Developer's Corner | 1 | 09-10-2006 07:17 AM |
Can this be done - remove javascript from a page | ScottMattes | Workshop | 1 | 05-17-2006 01:27 AM |