Skip to main content
Known Participant
September 7, 2020
Question

Hiding and showing a playbar button with Javascript

  • September 7, 2020
  • 2 replies
  • 531 views

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';

and

var btnFwd=document.getElementById('Forward');
btnFwd.style.visibility='hidden';

respectively.

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.

This topic has been closed for replies.

2 replies

TLCMediaDesign
Inspiring
September 11, 2020

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

 

else

 

execute JS to show button

Known Participant
September 11, 2020

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 🙂

Paul Wilson CTDP
Community Expert
Community Expert
September 9, 2020

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. 

Paul Wilson, CTDP
Known Participant
September 11, 2020

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!

TLCMediaDesign
Inspiring
September 11, 2020

In all of the testing I've done, onExit is actually executed on the first frame of the next slide.