Skip to main content
Nov 10, 2016 1:37 PM UTC
Question

I have a pdf page with 6 buttons. How do I change the action using javascript?

I have a page with 6 buttons.  How do I change the action using javascript?

This topic is closed to new replies. Start a new post to keep the conversation going.

7 replies

Nov 10, 2016 5:39 PM UTC

I am looking to open a bookmark with the code below instead of going to a page number.

var f = this.getField("Button1");  f.setAction("MouseUp", "this.pageNum = 1";

Translate
try67
Community Expert
Community Expert
Nov 10, 2016 6:27 PM UTC

You'll need to iterate over the entire bookmark tree, looking for that bookmark's name, and when you find it you can use the execute method to run the action associated with it.

Translate
Nov 10, 2016 4:09 PM UTC

Thanks.  Can you also tell me how to set the action to open a bookmark?

Translate
try67
Community Expert
Community Expert
Nov 10, 2016 4:17 PM UTC

What do you mean by "open a bookmark", exactly?

Translate
Joel Geraci
Community Expert
Community Expert
Nov 10, 2016 3:33 PM UTC

Something like this...

this.getField("BUTTONNAME").setAction(trigger, code);

The trigger is a string and can be any one of...

MouseUp

MouseDown

MouseEnter

MouseExit

OnFocus

OnBlur

Keystroke

Validate

Calculate

Format

code is also a string but it's the JavaScript that gets executed this this...

"app.beep(0);"

Translate