Skip to main content
November 10, 2016
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

November 10, 2016

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
November 10, 2016

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
November 10, 2016

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

Translate
try67
Community Expert
Community Expert
November 10, 2016

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

Translate
Joel Geraci
Community Expert
Community Expert
November 10, 2016

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