Skip to main content
Participant
December 15, 2021
Question

Trying to create a 2 second delay using javascript

  • December 15, 2021
  • 2 replies
  • 1868 views

Hello, Ken here from the UK

 

I am trying to create a two second delay in my javascript routine using this syntax which I know to be wrong:

 

var delay  = 2000;

setTimeout(blank() {

 this.getField(“blank6a”).display = display.visible

}, delay);

 

Could anyone provide help in how I can get a two second delay before a text (blank) is visible?

 

Thank you

 

This topic has been closed for replies.

2 replies

try67
Community Expert
Community Expert
December 16, 2021

Try this:

 

var delay = 2000;
app.setTimeout("this.getField(\"blank6a\").display = display.visible;", delay);
Participant
December 18, 2021

Try67,

 

Thank you but this code did not work either. I do believe.however, we are near.

 

Best Regards,

 

Ken

try67
Community Expert
Community Expert
December 18, 2021

Try it now:

 

var delay = 2000;
var to1 = app.setTimeOut("this.getField(\"blank6a\").display = display.visible;", delay);
Thom Parker
Community Expert
Community Expert
December 15, 2021

Use the "app.setTimeout()" function:

https://opensource.adobe.com/dc-acrobat-sdk-docs/acrobatsdk/html2015/index.html#t=Acro12_MasterBook%2FJS_API_AcroJS%2Fapp_methods.htm%23TOC_setTimeOutbc-35&rhtocid=_6_1_8_6_1_34

 

You could almost use the same code you've shown in the post, except there may be an issue with "this".  I usually store the current doc object in a variable that can be reached globally, just to avoid any local context issues.

 

 

 

Thom Parker - Software Developer at PDFScriptingUse the Acrobat JavaScript Reference early and often
Participant
December 16, 2021

Tom,

 

Thank you for your response. I am not a javascript coder having only used routines I have developed from Google searches. Your recommendation to use app.setTime function leaves me baffled as I am afraid as I simply cannot work out the syntax from the link you provided.

 

Would you kindly help me by providing me the code syntax for what I would like to achieve?

 

Best regards,

 

Ken