Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Changing BG of passages based on tags?

Okay so, I have my story all done and I have a couple of my passages tagged with "bg." I want to use JavaScript to change the background image for a couple of passages.

I'm using Harlowe.

Admittedly, JavaScript isn't my strong point, but I've figured it out for the most part (I think).

So, how do I tell the javascript to change the background based on the tag? It says I need to define "bg" when I try to run it, so do I need to use
$bg
before the main script?

I hope this made sense. JavaScript is below:
if (tags = bg) {
	document.body.style.backgroundImage = "bg1.png";
} else {
	document.body.style.backgroundImage = "bg2.png";
}

Thanks in advance!

Comments

  • There doesn't appear to be a way to edit? Hm.

    I've defined both "bg" and "tags" now. With var instead of $. Mixed up my languages there.

    I still can't get this to work.

    Sorry for the bump.
  • Quoting from another user's response to a similar question.
    It's not much help for right now, but passage-specific CSS changer macros are in the works for a future version of Harlowe.

    But for now, I recall someone was trying this, though I've never tried it myself.
  • This post may do what you need.
Sign In or Register to comment.