I want to hide the "Forward" button on the playbar when on the last slide of the project, but show it again should the user navigate back to another topic. In the browser console I can toggle the Forward button between visible and hidden using:
var btnFwd=document.getElementById('Forward'); btnFwd.style.visibility='visible';
var btnFwd=document.getElementById('Forward'); btnFwd.style.visibility='hidden';
I have therefore added the corresponding code to the slide On Enter and On Exit actions. The button hides on slide entry but does not display when navigating to another slide. I have tried adding a short delay before the code executes but that makes no difference.
Can anyone shed any light on this? I have worked around it by adding some code to the On Enter advanced action of the other slides that checks if the button is visible and if not displays it, but I would like to understand why this is happening.
You would likely need the show script for all the other slides or at least the previous to final slide if you only allow linear navigation. The reason is the on exit action of the final slide is seldom run. Navigating away from the slide doesn't run the on exit action. The on exit action is run if the slide plays through to the very end of the slide without being interrupted by click boxes, buttons or the user clicking on the playbar to navigate away.
Thanks Paul for the explanation. The On Exit should be running in this instance because to navigate away the user would need to use the ToC or back button on the play bar. Maybe it is not run when using the ToC. Very confusing really but now I know!
In all of the testing I've done, onExit is actually executed on the first frame of the next slide.
Not sure, David. I definitely recommend to avoid the On Exit action. In some of the Quick Start Projects it is used to pause the slide. And it will pause on the present slide with the content of the last frame. Although I also think the action, if it works correctly, is done right fater the last frame.
I think I read/heard Rod Ward saying the same thing.
That is very possible...
If you just want to hide it on the last slide, in your slide enter advanced actions, add a conditional tab
if cpInfoCurrentSlide is equal to cpInfoSlideCount
execute JS to hide button
execute JS to show button
Now that is a good idea! I shall try it.
I was trying to only execute the relevant code on the last slide, but this does make sense. Thank you 🙂