Is it possible to disable the back button starting at a specific passage?

+1 vote
asked Sep 10, 2017 by ShogunTaira (160 points)

I've found a bit of information on this in the past but it doesn't seem to have any answers in the latest version of Harlowe. In addition, looking through the Q&A boards here hasn't given me results I'm looking for either. I'd like to have my back button disable permanently at a particular passage. If possible, Id also like to know if it can then be re-enabled at a later passage, kind of like an on/off switch.

Thanks in advance!

2 Answers

0 votes
answered Sep 11, 2017 by greyelf (88,750 points)
selected Sep 11, 2017 by ShogunTaira
Best answer

You can't disable the History system but you can hide the Undo and Redo links that it displays within the tw-sidebar element, and the Basic Harlowe Passage Tag Based Styling thread in the old Forums Archive contains all the information and some of the components needed to achieve this.

1. Using Javascript within a Passage to assign a known CSS class to an HTML element.
The following assigns a no-navigation CSS class to the main tw-story element of the story, you would use it in the first passage of the set of passages you don't want the History navigation links be available in.
You will also need to use it within the last passage of that set to handle the situation where the Reader uses the Undo link to rewind History back to that last passage.


2. Using Javascript within a Passage to remove a known CSS class from an HTML element.
The following removes the no-navigation CSS class from the main tw-story element of the story, you would use it in the first passage of your story where you want the History navigation links to be available again.


3. Using CSS based on the no-navigation CSS class to hide the contents of the tw-sidebar element.
Place the following within your story's Story Stylesheet area. tw-sidebar {
	display: none;


commented Sep 11, 2017 by ShogunTaira (160 points)
Thanks for this! I managed to read up on the post here and finagled it appropriately. Cheers!
0 votes
answered Sep 10, 2017 by RealityDev (1,130 points)
Why not keep a Boolean variable that checks at the start of each passage, if disabled == true and if so, render the appropriate CSS to disable it. Then just flick the Boolean between true/false as needed.
Welcome to Twine Q&A, where you can ask questions and receive answers from other members of the community.

You can also find hints and information on Twine on the official wiki and the old forums archive.

See a spam question? Flag it instead of downvoting. A question flagged enough times will automatically be hidden while moderators review it.