1 Reply Latest reply on Nov 20, 2012 4:52 AM by [Jongware]

    Create an action for a button on click event

    3dsolutions Level 1


      I am newbie on indesign. I like to know how to add  a simple javascript to a button on click event.

      I like to have control on click event to hide or show layers.

      In Acrobat the following javascript will work to toggle the visibility of a layer called layer1. Is it the same for indesing?

      var docOCGs = this.getOCGs();

      for (var x=0; x < docOCGs.length; x++)


      if(docOCGs[x].name == "layer1")


        docOCGs[x].state = !docOCGs[x].state;





        • 1. Re: Create an action for a button on click event
          [Jongware] Most Valuable Participant

          Do not confuse "PDF events" (clicking a button, showing/hiding layers) with "InDesign events" (which are things that happen inside InDesign only, when working on an InDesign document).


          If InDesign runs a script, it changes the state of the InDesign document. You can add buttons to an InDesign document but those would not "do" something inside InDesign, because the button behavior is only visible in an exported PDF. Similar, you cannot write an InDesign Javascript to "do" something when clicked in the exported PDF -- it's a different level.