body {
background-color: white;
color: darkgrey;
font-family: Futura,Impact,Helvetica,sans-serif;
font-size: 125%;
}
a {
color: red;
}
a:hover {
color: crimson;
text-decoration: none;
border-bottom: 4px solid crimson;
}
.forest {
background-color: Beige;
color: cornflowerblue;
font-size: 200%;
}
.desert {
background-color: LimeGreen;
color: cornflowerblue;
font-size: 200%;
}
.land {
background-color: Black;
color: cornflowerblue;
font-size: 200%;
}
.ocean {
background-color: Blue;
}
Starting with the CSS stylesheet above, I would like to be able to change the background color of certain areas on the fly, when the player clicks a link. For example, if the player is in a location tagged "forest" (which starts with a Beige backgroundColor) and clicks an element of text displayed as "green forest" the appearance of all similarly tagged pages should immediately and everafter be changed to a Green Background.
I am working in Twine 2, Sugarcube 2.28.2
I done a lot of research on this question already (with google) and the closest I've come is this line of code
<<linkreplace "Change Color">>
<<script>>
document.body.style.backgroundColor = "Green";
<</script>>
<</linkreplace>>
Which applies the change immediately, but also globally (rather than being tag specific). Also, this seems to change the colors of the edges of the window, rather than the background behind the text itself.