Expand my Community achievements bar.

Radically easy to access on brand approved content for distribution and omnichannel performant delivery. AEM Assets Content Hub and Dynamic Media with OpenAPI capabilities is now GA.

script called as many times as masterpage is used

Avatar

Former Community Member
Hello,



When people build a form with n pages, and a global script within, there's a strange behaviour with the script.



When this form loads, this global script is called as many times as the total number of pages in my form, like if it was instanciating it again and again



How avoid it ?



Thanks for your help !
1 Reply

Avatar

Level 5
Here some sample JavaScript code that might help you resolve the issue.



var curPageNum = xfa.host.currentPage + 1; // this is index

// based starts with 0



if (curPageNum == 1) {

// run your current script here then it will run only one

//time on page 1

}