Skip to main content
New Participant
March 2, 2023
Question

Running js using a button (indesign, fixed format, epub)

  • March 2, 2023
  • 2 replies
  • 1449 views
Looking to run the below script from an exported fixed formatted epub, using a button. Is this possible?
 

 

var doc = app.activeDocument;

for (var i = 0; i < doc.pages.length; i++) {
  var page = doc.pages[i];
  page.select();

  var multiState = page.multiStateObjects.itemByName("Multi-state-1");
  multiState.activeStateIndex--;

}

 

This topic has been closed for replies.

2 replies

Loic.Aigon
Brainiac
March 3, 2023

Once the ePub is done, the end-product has no connection at all with InDesign DOM so your code cannot work at all as fired from a button inside the ePub.

I would look at button interactivity options inside InDesign. Here is an example:

 

 

James Gifford—NitroPress
Brainiac
March 3, 2023

So what is the use of the JS code at export time? If it can't be linked to internal functions like buttons, why is it offered at all? (It's one of the areas of EPUB export about which I know next to nothing, but I can't believe Adobe would just stick that option in there for no good purpose...)

 

Loic.Aigon
Brainiac
March 3, 2023

I was pointing out the fact the code our friend wanted to run was ExtendScript related to InDesign. I think it's quite obvious that if the ePub once opened in an external application (or think of a Kindle) cannot execute a code that normally is executed through the InDesign Script engine. 

Once that said, I am not the ePub expert but the js there is mostly to be run by the reader app and the code is likely to be vanilla javascript, not InDesign ExtendScript. 

I tried to find some Adobe literature on the topic without much luck but I happily delegate this to our friend.

Loic

 

James Gifford—NitroPress
Brainiac
March 2, 2023

You can add JS to an EPUB export in the Export Options | JavaScript dialog.

 

I don't know anything about how to hook it in from within InDesign, though.