I want to remove the button on some pages but show it on most pages of the survey.
Try to replace the placeholder by the empty string on pages 1 and 2.
replace('%btnExit%', '');
Then, on page 3, use buttonToPage()
.
You may wonder why to place the first code on page 2 as well? This would be necessary, if (a) you started testing as of page 2 or (b) you allow for a back button, and people could go back from page 3 to page 2.