Highlighted

Hiding and showing a playbar button with Javascript

Participant ,
Sep 07, 2020

Copy link to clipboard

Copied

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.

Topics

Advanced

Views

69

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more

Hiding and showing a playbar button with Javascript

Participant ,
Sep 07, 2020

Copy link to clipboard

Copied

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.

Topics

Advanced

Views

70

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Adobe Community Professional ,
Sep 09, 2020

Copy link to clipboard

Copied

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 | https://captivateteacher.com

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Participant ,
Sep 11, 2020

Copy link to clipboard

Copied

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!

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Sep 11, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Most Valuable Participant ,
Sep 11, 2020

Copy link to clipboard

Copied

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.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Participant ,
Sep 11, 2020

Copy link to clipboard

Copied

I think I read/heard Rod Ward saying the same thing.

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Lilybiri LATEST
Most Valuable Participant ,
Sep 11, 2020

Copy link to clipboard

Copied

That is very possible...

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Adobe Community Professional ,
Sep 11, 2020

Copy link to clipboard

Copied

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

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Participant ,
Sep 11, 2020

Copy link to clipboard

Copied

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 🙂

Likes

Translate

Translate

Report

Report
Community Guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
Reply
Loading...
Resources
Captivate User Guide
New Group