• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers

Help with Javascript function to show a hidden button with setTimeout

New Here ,
Jun 26, 2018 Jun 26, 2018

Copy link to clipboard

Copied

I have an interactive PDF with a form field button called “Nav_Forward_Page_14” that is set to hidden. I want the button to be visible 5 seconds after the page containing the button loads; so on Page Properties (for the page with the button), I've tried adding the following Javascript on page load, with no success:

setTimeout(function() {

this.getElementById("Nav_Forward_Page_14").style.display = "inline";

}, 5000);

Thinking that I may have the function wrong, I also tried:

setTimeout(function() {

this.getElementById("Nav_Forward_Page_14").display = display.visible;

}, 5000);

After more research, I've also tried:

function runImage() {

this.getField("Nav_Forward_Page_14").display = display.visible

}

run = app.setTimeout("runImage()", 5000);

Please help me correct the function necessary to show the hidden button after a delay on page load in a PDF. Thank you in advance!

TOPICS
Acrobat SDK and JavaScript , Windows

Views

401

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Community Expert , Jun 26, 2018 Jun 26, 2018

The latter code will work, if you change it from setTimeout to setTimeOut ...

Likes

Translate

Translate
Community Expert ,
Jun 26, 2018 Jun 26, 2018

Copy link to clipboard

Copied

The latter code will work, if you change it from setTimeout to setTimeOut ...

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 03, 2018 Jul 03, 2018

Copy link to clipboard

Copied

I have a follow up question, please.  Why, and what can I do (if anything) about...

Sometimes when I go to the page with a series of buttons on setTimeOut, all of the buttons appear as scripted; but sometimes, some buttons don't appear at all - like the first, second and fifth buttons only will appear.  When I leave the page and return to it, maybe all of the buttons will appear, none or some .  Thoughts?  I can provide the code if you'd like - it does work, but not with consistency.

Thanks!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2018 Jul 03, 2018

Copy link to clipboard

Copied

Yes, please provide the code.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 03, 2018 Jul 03, 2018

Copy link to clipboard

Copied

Sure, please see below, (and thank you ).

Oh, and here's more info - I placed the below script on the Page Open action for this page.  The Topic# buttons are set as visible.  And, I added hide actions for each Topic button before the javascript on page load to hide the topics (I want to ensure that when the page is revisited it starts over blank.)

function runImage10() {

this.getField("Topic1").display = display.visible

}

run = app.setTimeOut("runImage10()", 2500);

function runImage11() {

this.getField("Topic2").display = display.visible

}

run = app.setTimeOut("runImage11()", 3800);

function runImage12() {

this.getField("Topic3").display = display.visible

}

run = app.setTimeOut("runImage12()", 6500);

function runImage13() {

this.getField("Topic4").display = display.visible

}

run = app.setTimeOut("runImage13()", 8900);

function runImage14() {

this.getField("Nav_Forward_5").display = display.visible

}

run = app.setTimeOut("runImage14()", 9000);

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 26, 2018 Jun 26, 2018

Copy link to clipboard

Copied

Yay!  Thank you

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Jul 03, 2018 Jul 03, 2018

Copy link to clipboard

Copied

Don't use the same variable ("run") for each command. Name them run1, run2, run3, etc.

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 03, 2018 Jul 03, 2018

Copy link to clipboard

Copied

LATEST

Many thanks again!

Likes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines