cyrix
August 23, 2022, 12:08pm
1
I have the following code in Story-JavaScript which applies to all passages:
// (A) PREVENT CONTEXT MENU FROM OPENING
document.addEventListener(“contextmenu”, (evt) => {
evt.preventDefault();
}, false);
However, on one specific passage, I don’t want this script to be effective. How can I turn off JS for just one passage?
Thanks.
Twine Version: 2.4.1
Story Format: SugarCube
cyrix
August 23, 2022, 1:39pm
3
Could you please give an example of how to write it in a passage? I am not familiar with writing JS directly in a passage.
The passage I will be removing the JS effect is the last passage so I don’t need to add it back.
Thanks.
Chapel
August 23, 2022, 7:18pm
5
Just use an if statement.
document.addEventListener(“contextmenu”, (evt) => {
if (passage() !== "name of passage") {
evt.preventDefault();
}
}, false);
note : If the purpose of that contextmenu event listener is to prevent the Readers from “cheating”, then (as it’s already been shown to you) that method is useless because it is so easily for them to bypass.